Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Unsupported HTTP method \"get\" for this action


#1

http://mysite/testrail/index.php?/miniapi/add_result/10000&key=mykey
Post body
status_id=1&comment=Test&version=Test

I am getting below response:
{Unsupported HTTP method “get” for this action."}

Even though I used POST why is the return error saying GET?

Using test rail version 2.6


#2

Hello,

Thanks for your posting. Would it be possible to send the full request including sample code to our help desk via email (contact@gurock.com)? Which tools or libraries do you use to send the HTTP request (e.g. curl or something else)?

Regards,
Tobias


#3

Hi, I am having the same issue. This is the python snippet I am using to send the request:

import requests
import json

base = 'http://<my-account>.testrail.net/index.php?/api/v2/'
user = '<my-email>'
password = '<my-password>'

headers = {'Content-Type': 'application/json'}
response = requests.post(base + 'add_result/1', auth=(user, password), data=json.dumps({'status_id': 1}), headers=headers)

Snippet for GET works as expected - returns JSON object in response.

headers = {'Content-Type': 'application/json'}
response = requests.get(base + 'get_project/1', auth=(user, password), headers=headers)

Thanks for your help. They advertised python API package seem obsolete and also does not work (that is why I am using python requests library).


#4

The problem is that you are trying to use http:// instead of https:// for your TestRail Hosted account, which will result in a redirect and then a GET request. It’s important to use https:// with TestRail Hosted.

I hope this helps!


#5

This resolved it.

Thanks for fast response.


#6

Hi! I´m having the same problem.
For sending HTTP request I´m using curl.

And I also want to add a result like failed. In the end I want to use our automatic testing tool for it, but first I have to test it manually.

curl --insecure -H “Content-Type: application/json” -u "mail@mail.de xxxx" “https://10.241.4.15/testrail-staging/index.php?/api/v2/add_result/954

Do I have to put the result to the end like: …add_result/954/failed ?

And I also have the error message with unsupported http method…

Thanks


#7

Hey @Travelstar,

Thanks for your posting. You would need to submit data like this as part of the HTTP POST body and the expected format would be JSON:

http://docs.gurock.com/testrail-api2/reference-results#add_result

Please see “Request example”.

There’s also a full example on how to submit data using curl here:

http://docs.gurock.com/testrail-api2/accessing#write_request

I hope this helps!

Cheers,
Tobias


#8

Hey Tobias,

thanks for your quick reply. I´d tried it again and now I´ve got another Problem -.-

curl --insecure -H “Content-Type: application/json” -u "xxx@xxx.de:xxxx" -d ‘{“status_id”:1}’ “https://testrail/index.php?/api/v2/add_result/954

error message: invalid or incomplete json string

Thanks for helping


#9

Now it´s solved… :slight_smile:

Thanks


#10

Good to hear it’s working now :slight_smile:

Cheers,
Tobias


#11

HI ,

I am also facing similar issue. I am doing curl with following command

/usr/bin/curl --insecure -L -H Content-Type:application/json -u username:password https://ip:port/testrail/api/v2/add_run/91 -d '{ “suite_id”: “2918”, “name”:“test2018-02-07-07:52:58” }'
Output:
{“error”:“Unsupported HTTP method “get” for this action.”}

All get API’s are working fine for me. Is there something which I am missing in case of post API.