Failure in updating Jira label using REST API Edited

I'm trying to update a Jira Label using postman and curl but both of the methods are failing with different error message.


 curl -D- -u userName -X PUT --data "{ "update": { "labels": [ {"add" : "new_label"} ] } }" -H "Content-Type: application/json"

Formated input json



HTTP/1.1 400 Bad Request
Cache-Control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Date: Thu, 20 Jul 2017 00:32:30 GMT
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=7D2377622EC43724B9EF35E0CA7F6E20; Path=/; Secure; HttpOnly
Set-Cookie: atlassian.xsrf.token=BEF9-GHD2-UUG5-5KAQ|dc2355ac9338b0cc1396b1fd68a8268785ac6589|lin; Path=/; Secure
X-AREQUESTID: 32x6573810x14
X-ASEN: SEN-2063834
X-Content-Type-Options: nosniff
X-Seraph-LoginReason: OK
transfer-encoding: chunked
Connection: keep-alive

{"errorMessages":["Unexpected character ('u' (code 117)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@6e73489c; line: 1, column: 4]"]}%

With postman I'm getting following error:

<title>Apache Tomcat/7.0.55 - Error report</title>
<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;} {color : black;}HR {color : #525D76;}-->
<h1>HTTP Status 415 - Unsupported Media Type</h1>
<HR size="1" noshade="noshade">
<b>type</b> Status report
<u>Unsupported Media Type</u>
<u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u>
<HR size="1" noshade="noshade">
<h3>Apache Tomcat/7.0.55</h3>


Does anyone know what is wrong here?

2 answers

1 accepted

Use " ' " at the beginning and end of you data.

This worked for me fine:

curl -u stefana -p -X PUT -H "Content-Type: application/json" --data '{"update":{"labels":[{"add":"test"}]}}'  http://domain/rest/api/latest/issue/PM-7697

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

164 views 1 17
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you