Unable to use REST resource from gadget - 415 response is not in JSON format

Lloyd Roles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2012

All,

I am attempting to use the following REST resource from a standalone Jira 4.4 gadget.

This is the resource I am trying to fetch, but from my development machine and the same from the atlassian website: (localhost:2990/jira/rest/api/latest/issue/ABC-123)

https://jira.atlassian.com/rest/api/latest/issue/JRA-9

The response looks like JSON to me.

However, when I use an AJAX query from my gadget, I get

GET localhost:2990/jira/rest/api/latest/issue/ABC-123 415 Unsupported Media Type

The response is being returned as HTML rather than JSON. This is the response from tomcat:

The server refused this request because the request entity is in a format not supported by the requested resource for the requested method ()

Here is my AJAX call:

args: [{

             key: "issueData",

             ajaxOptions: function() {

                 return {

                     url: "/rest/api/latest/issue/ABC-123"

                 };

             }

      }]

I've tried adding `dataType: "json"` and `contentType: 'application/json'` to the ajax request but nothing doing.

Howcome it is json when i query through the browser, but HTML when I query through the gadget?

I am desparate to solve this quickly. Any help at all would be much appreciated.

Thanks in advance,

ns

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Lloyd Roles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2012

Needed to add the contentType: "application/json" to the HTTP request sent by AJAX:

args: [{
       key: "issueData",
       ajaxOptions: function() {
           return {
               contentType: 'application/json',
               url: "/rest/api/2.0.alpha1/issue/CRDTRK-1"
           };
       },
}]

TAGS
AUG Leaders

Atlassian Community Events