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

API requires application/json


#1

I’m working on an integration at the JSON API level that is running into some challenges. When we try to do a jquery ajax call, we receive errors that we can’t call it because it doesn’t exist on the same server. The alternative is using JSONP.

However, with JSONP, there is no way to set the Accept: header to application/json. The result is an ongoing error indicating that we haven’t passed the right accept header. Is it truly critical to fail on this small detail, because it seems to be preventing us from integrating it into our defect system.

Thanks


#2

Hello Chris,

Thanks for your posting. JSONP is not really supported by the API as this would require returning the data as a JS expression as far as I understand it:

http://en.wikipedia.org/wiki/JSONP

You could workaround the same origin policy for Ajax calls by doing the TestRail API call on the server as follows:

[list=]
[
]Client issues Ajax call to your server[/]
[
]Your server sends a call to TestRail’s API[/]
[
]Your server sends the TestRail response back to the client[/*]
[/list]

Would this work for you?

Regards,
Tobias


#3

In this case we were attempting to call from JIRA to TestRail, so adding a custom proxy into the JIRA environment would be difficult. We did find a workaround by configuring IIS to provide an Access-Control-Allow-Origin: * header. This instructed web browsers to allow cross site requests to the server.

From this we were able to effectively create a JIRA plugin that could provide status of specific tests inline and dynamically. We’re currently experimenting with this and with remote application links to determine the best way to integrate.