Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

PUT request for jira issue

Tobias Hofer January 10, 2012

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 10, 2012

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.

Tobias Hofer January 11, 2012

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

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2012

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.

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2012

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.

Tobias Hofer January 12, 2012

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" });

Tobias Hofer January 12, 2012

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;

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2012

Here... try this...

Basically, your PUT should have the following body:

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

Tobias Hofer January 15, 2012

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\"}}"

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 15, 2012

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

0 votes
Tobias Hofer January 16, 2012

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

Mark Everest June 12, 2012

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.

0 votes
JamieA
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.
January 10, 2012

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.

Tobias Hofer January 10, 2012

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

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

JamieA
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.
January 10, 2012

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

0 votes
Tobias Hofer January 10, 2012

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;

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events