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

Issue with the API after upgrading to the latest version


#1

I am getting the following error when trying to get a JSON result from the API:

{“result”:false,“error”:“Accept header invalid (use Accept: application/json)”}

Here’s the call:

http://IP/testrail/index.php?/miniapi/get_run/3521&key=XXX

And in test rail it is in fact a Test Run

http://IP/testrail/index.php?/runs/view/3521

This worked before upgrading from an older version of the API. Any ideas on what needs to be changed?

Thanks,
Matt


#2

Hi Matt,

Thanks for your posting. The API requires that you set the “Accept: application/json” HTTP header for all requests. While this was also needed for previous versions of the API (as noted in the documentation), previous API versions didn’t enforce this and didn’t return an error when the header wasn’t sent. So you would basically just need to set the header on all requests to resolve this. We can also take a look at your code and suggest the best way to do this if you want to share a code snippet.

Thanks,
Dennis


#3

Thanks Dennis,
I updated my Java interface to include ‘connection.setRequestProperty(“Accept”, “application/json”);’ in my GET and POST requests.

Matt