It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

PUT request for jira issue

Im trying to update a field in an issue over REST API. But I always get "MethodNotAllowed" Error when I drop a Put request. GET requests work. Anybody know what I am doing wrong?

4 answers

1 accepted

0 votes
Answer accepted

Before I get into coding against a REST API, I usually try to access the resource through curl or some basic client that I have full control over. Another tool you can try out is the Atlassian REST API Browser. We just installed this on our public JIRA instance. You can access it here: https://jira.atlassian.com/plugins/servlet/restbrowser#/com-atlassian-jira-rest-jira-rest-filter

Make sure you log in first.

thanks. this looks like a good plugin. where can I get it?

It seams to me that the PUT request is not yet implementet as I can not see such a request in the REST Browser for

/issue/{issueIdOrKey}/editmeta

But it is documented in http://docs.atlassian.com/jira/REST/5.0-rc2/#id3419201

Is there an example somewhere how to update a field in an issue over REST

For now, you can install it in UPM with this URL: https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/devrel/developer-toolbox-plugin/1.1-rc2/developer-toolbox-plugin-1.1-rc2.jar

We're in the process of adding it to the Plugin Exchange.

Sorry... forgot to answer your question re: editmeta. I don't see a PUT method on editmeta in the documentation:

http://docs.atlassian.com/jira/REST/5.0-rc2/#id3419731

Only a get.

ah yes I just saw. There is a PUT methiod on

/rest/api/2/issue/{issueIdOrKey}

But when I try to update the summery field it sais "bad request". I'm sure Im forming the json wrong. But I can't figure out how. Here is my code:

var request = new RestRequest();

request.RequestFormat = DataFormat.Json;

request.Method = RestSharp.Method.PUT;

request.AddBody(new { summary = "test" });

Im a big step further now but I get this error from jira: errorMessages\":[],\"errors\":{\"summary\":\"Operation value must be a string

code:

var json = new JObject(

new JProperty("update",new JObject(new JProperty("summary",

new JArray(

new JObject(

new JProperty("set","test01" )))))));

var request = new RestRequest();

request.RequestFormat = DataFormat.Json;

request.Method = RestSharp.Method.PUT;

request.AddBody(json);

RestResponse response = client.Execute(request);

string content = response.Content;

Here... try this...

Basically, your PUT should have the following body:

{
  "fields": {
    "summary": "A new summary"
    }
}

Thank you. This works over the REST browser Plugin. But when I send the same string over my c# app i get the following error:

Content = "{\"errorMessages\":[\"Can not deserialize instance of com.atlassian.jira.rest.v2.issue.IssueUpdateBean out of VALUE_STRING token\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@54046d9c; line: 1, column: 1]\"]}"

If I serialize it as a json I get this:

Content = "{\"errorMessages\":[],\"errors\":{\"summary\":\"Operation value must be a string\"}}"

@e3k do you have any way of sniffing the actual request/response the gets sent/received? I'm not a C#'er.

var jsonDataSerialize = request.JsonSerializer.Serialize(jsonData);

request.RequestFormat = DataFormat.Json;

request.Method = RestSharp.Method.PUT;

request.AddBody(JSONSharp.Values.JSONStringValue.ToJSONString(@"{""update"": {""summary"": [{""set"": ""Bug in business logic""]}}"));

RestResponse response = client.Execute(request);

string content = response.Content;

What version? There doesn't seem to be any such method... http://docs.atlassian.com/jira/REST/latest/

POST is the normal verb for updating, but that doesn't seem possible either.

http://docs.atlassian.com/jira/REST/5.0-rc2/#id3419065

I've installed this version. Hoped it would work..

Oh, my bad... sorry, not sure then.

Thanks for the tipp. It looks like a bug in this third party REST client that I used. It did not send the string correctly. I switched to the basig HTTPRequest and it works now. Thank you

e3k - would you be prepared to share some of your .NET code?

I am using a WebRequest, but it is failing with an annoying "(400) Bad Request" error.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Off-topic

Friday Fun: Virtual dance party!

Do dance parties help you relieve stress? How about *virtual dance parties*? My team holds virtual dance parties to brighten the mood of a tough day or celebrate an upcoming weekend.  Want t...

180 views 21 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you