“Unsupported media type“ when trying to create issue using rest

Michael Danielsson
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.
July 22, 2013

Hi

I try to add a new issue to JIRA. We installed the latest JIRA to our server and checked the API. We are able to authenticate, list issues, get one specific issue, delete issue… but when we try to create a new issue, we are still getting error: “Unsupported media type“ in the response. We used the example from the API documentation, it is basically 100% copy and we still face the problem. Any idea, is it somehow known to you?

He is the part of our code:

string issueToCreate = "{\"fields\":{\"project\":{\"key\":\"SIM\"},\"summary\":\"REST 1 merry gentlemen.\",\"description\":\"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\":{\"name\":\"Bug\"}}}";
          
RestClient client = new RestClient();
client.BaseUrl = "http://10.14.41.152:8076/rest/api/latest/";
client.Authenticator = new HttpBasicAuthenticator(username, password);

// connection established
RestRequest request = new RestRequest("issue", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddBody(issueToCreate);
request.RequestFormat = DataFormat.Json;
IRestResponse response = client.Execute(request);

Thank you very much in advance!


1 answer

1 accepted

2 votes
Answer accepted
LucasA
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.
July 22, 2013

Hi Michael,

"Unsupported media type" tipically occurs when the header "Content-Type: Application/json" was not present on the REST request. Can you make sure the "request.AddHeader" is being correctly parsed by your code?

I strongly suggest you to also test the request using Postman REST Client first, just to make sure JIRA is receiving the requests correctly.

Best regards,
Lucas Timm

Suggest an answer

Log in or Sign up to answer