c# REST API - Updating Issue not work

Andrea Marinoni September 25, 2019

Hi,

i'm trying to edit an issue (status,summary,ecc..) from my website.

the url i'm trying to consume this API (Jira API i found at this link:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-issue-issueIdOrKey-editmeta-get

):

 

"{BaseUrl}/rest/api/3/issue/{TicketKey}/editmeta"

but the response return 405 (Method Not Allowed)

 

Here the code i written:

 

var obj = new UpdateViewModel { update = new UpdateTicketViewModel { summary = new List<UpdateSummary>() } };
obj.update.summary.Add(new UpdateSummary { set = model.Summary });
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Headers.Add("Authorization", $"Basic {Base64Encode(decrypted)}");
httpWebRequest.Headers.Add("Accept-Language", "en-US");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "PUT";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
json = JsonConvert.SerializeObject(obj);
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}

 

Here the JSON i'm trying to post.

{"update":{"summary":[{"set":"TEST ANDREA"}]}}

Anyone can help me?

Thanks,

Andrea

 

1 answer

1 accepted

2 votes
Answer accepted
Michael Kuhl _Appfire_
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.
September 25, 2019

Hi Andrea - The doc you pointed to is for Atlassian apps (add-ons).  Here's the (very similar) call to edit an issue from an external source:

curl --request PUT \
--url '/rest/api/3/issue/{issueIdOrKey}' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"fields": {
"summary": "Completed orders still displaying in pending"
}
}'

 

Andrea Marinoni September 26, 2019

Thanks for the report. Now i'm trying to change the status of an issue but it not work.

This is the JSON i'm trying to post:

{
"fields":{
"summary":"TEST ANDREA 2"
},
"transition" : {"id" : "1001"}

}

The code i receive is 204 No Content. The summary changes but not the status.

Can i edit it by REST API or not?

Thanks,

Andrea

Suggest an answer

Log in or Sign up to answer