Reputation: 2478
I am trying to update a field in a Jira issue by using a curl request with the Jira API and used the last curl request from the Jira API tutorial to create my request to change the summary field of the ticket.
I used this curl command (replaced actual domain with "DOMAIN" and my api token with "MY_TOKEN"):
curl -D- -u [email protected]:MY_TOKEN -X PUT --data "data_file.json" -H "Content-Type: application/json" https://DOMAIN.atlassian.net/rest/api/2/issue/ZSTP-3511
My "data_file.json" looks like this:
{
"update" : {
"summary" : [{"set" : "Big block Chevy"}]
}
}
But the error message I receive is this:
PS C:\Users\de00180\Desktop> curl -D- -u [email protected]:MY_TOKEN -X PUT --data "data_file.json" -H "Content-Type: application/json" https://DOMAIN.atlassian.net/rest/api/2/issue/ZSTP-3511
HTTP/1.1 400 Bad Request
Server: AtlassianProxy/1.15.8.1
cache-control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Thu, 22 Oct 2020 11:00:15 GMT
ATL-TraceId: 2b748183a0112486
x-arequestid: e929fb72-6adc-4cb7-84e4-f38f36c6e342
x-aaccountid: 5aec0e222d1bf924e1fc693d
X-XSS-Protection: 1; mode=block
Transfer-Encoding: chunked
timing-allow-origin: *
x-envoy-upstream-service-time: 21
X-Content-Type-Options: nosniff
Connection: close
set-cookie: atlassian.xsrf.token=BP6L-4GZ3-UVOB-X2BO_044d61b5148f4471cb04a8c58ac8f12ab76f2fd2_lin; Path=/; Secure
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
{"errorMessages":["Unexpected character ('d' (code 100)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@5503a2e4; line: 1, column: 2]"]}
Another similar looking question on here was with a different error code and trying to change the quote chars did not work for me.
But I am also using Windows so perhaps it is connected to my operating system.
I also had a look at the curl and jira api error codes, but it did not help me solve this issue, since the error code 100 just stands for a "Continue" response in Jira.
How can I fix this error?
Upvotes: 0
Views: 705
Reputation: 692
The problem could be in the actual curl command. I see from this answer that one needs to put an '@' before the file name if you are referencing a file. Otherwise it takes the 'data_file.json' as the actual request body.
Try this:
curl -D- -u [email protected]:MY_TOKEN -X PUT --data "@data_file.json" -H "Content-Type: application/json" https://DOMAIN.atlassian.net/rest/api/2/issue/ZSTP-3511
Upvotes: 1