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

c# REST API - Updating Issue not work

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

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

 

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
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

932 views 8 25
Read article

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