Here is my command:
curl -X POST -L -D- --insecure --cookie cfk --data {'fields': {'project':{'key':'ABCD'},'summary':' Test.','description':'Creating an issue using the REST API','issuetype':{'id':'3'}}} -H "Content-Type: application/json" http://m.company.com/issues/rest/api/latest/issue/
I assume I am getting this error due to the formatting of --data. How should the --data portion of the CURL command be formatted? Or is there something else wrong?
Hi Theresa, you can see an example of REST call with CURL to create an issue in JIRA here. You can define the data portion as this example:
{ "fields": { "project": { "key": "TEST" }, "summary": "REST ye merry gentlemen.", "description": "Creating of an issue using project keys and issue type names using the REST API", "issuetype": { "name": "Bug" } } }
Cheers
I've studied the documentation and I think my json string is correct. Here is it (I removed the description field to make it shorter):
--data "{\"fields\":{\"project\":{\"key\":\"RTSD\"},\"summary\":\"ART Test.\",\"issuetype\":{\"id\":\"3\"}}}"
Do you see any issue with my --data json string?
Hi Theresa,
What if you run:
curl -k -D- -u admin:admin -X POST -H "Content-Type: application/json" --data "{\"fields\":{\"project\":{\"key\":\"RTSD\"},\"summary\":\"ART Test.\",\"issuetype\":{\"id\":\"3\"}}}" http://m.company.com/rest/api/latest/issue/
In short:
Cheers.
This command is successful:
curl -L -D- --insecure --cookie cfk -H "Content-Type: application/json" http://m.company.com/issues/rest/api/latest/issue/createmeta
so I am assuming that my original URL is correct.
The REST API has Siteminder in front of it. I already have the command to authenticate to Siteminder (hence the cookie in the CURL command), but I think that there is a problem in passing the POST data. When I submit a GET command to the REST API, it works with no problems. I no longer think my problem is how I am formatting the json data. Do you have any experience in getting a POST API call to work when going through Siteminder?
Hi Theresa, here there is an example of issue creation using CURL via REST:
ecrnt-06:~ tcomasseto$ curl -D- -u admin:pass -X POST --data "{\"fields\":{\"project\":{\"key\":\"TEST\"},\"summary\":\"REST ye merry gentlemen.\",\"description\":\"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\":{\"name\":\"Task\"}}}" -H "Content-Type: application/json" http://localhost:8080/jira625/rest/api/latest/issue HTTP/1.1 201 Created Date: Thu, 26 Jun 2014 13:10:21 GMT Server: Apache-Coyote/1.1 X-AREQUESTID: 610x10031x1 X-ASEN: SEN-L3611469 X-Seraph-LoginReason: OK X-ASESSIONID: 1rp5d23 X-AUSERNAME: admin Cache-Control: no-cache, no-store, no-transform X-Content-Type-Options: nosniff Content-Type: application/json;charset=UTF-8 Set-Cookie: JSESSIONID=357703688FAB2198109CF0CF4F4DA156; Path=/jira625/; HttpOnly Set-Cookie: atlassian.xsrf.token=B64A-MCV0-ICIO-W176|627f6395bced9d0b5ab18c7c60af922021c0b1d8|lin; Path=/jira625 Connection: close Transfer-Encoding: chunked {"id":"10307","key":"TEST-23","self":"http://localhost:8080/jira625/rest/api/latest/issue/10307"}ecrnt-06:~ tcomasseto$
The data portion in this example is
"{\"fields\":{\"project\":{\"key\":\"TEST\"},\"summary\":\"REST ye merry gentlemen.\",\"description\":\"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\":{\"name\":\"Task\"}}}"
If it doesn't work, one thing you may need to check is if there's any required custom field to create issues in this project. If so, you'll need to include the custom field value in your json.
I hope it helps
Got it. I needed to add --post302 to the CURL command line.
I just spent some time working on this problem until i found out i had an encoding problem in the file i was importing (and creating issues via rest from).
A german Umlaut "ü" in the imported data caused this error because i saved the file in a wrong encoding
yes, its work for me. Main thing is --data portion.if data portion is right ,then you code will be work.'
thanks Tiago Comasseto
Thanks, saved loads of time on my side
It looks like you're new here. Sign in or register to get started.