Hi all,
i m implenenting a tool to create issues to jira from php using REST
my request looks like this
curl -u erp:wasd --header "Content-Type: application/json" -X POST --data {"fields":{"project":{"key":"COMMON"},"summery":"Test ChargenNr","descrpition":"some description","issuetype":{"id":"5"}}} http://host.xy:post/rest/api/latest/issue/
the answer is
stdClass Object ( [errorMessages] => Array ( [0] => Unexpected character ('f' (code 102)): was expecting double-quote to start field name at [Source: org.apache.catalina.connector.CoyoteInputStream@37edb80; line: 1, column: 3] ) )
when i send a request without sending data all is fine.
the return of
curl -u user :pass Http://host.xy:port/rest/applinks/latest/manifest
is
..
[version] => 5.1.6 [buildNumber] => 785 [applinksVersion] => 3.7.3
..
what is wrong with my request to create a issues
thx in advance
Georg
Community moderators have prevented the ability to post new answers.
Hallo Nic,
I changed field names as shown in the example under
the curl command now looks like this
curl -u user:pass --header "Content-Type: application/json" -X POST --data {"fields":{"project":{"key":"COMMON"},"summary":"Test ChargenNr","description":"some description","issuetype":{"id":"5"}}} http://host.xy:port/rest/api/latest/issue/
unfortunatly I get the same error as befor
georg
Hi to all
after a bit more of reserce I found the solution to this problem
the data string had to be in double Quotes like this "{}" all double Quote inside the data string have to get escaped so the final command looks like this
curl -u user:pass --header "Content-Type: application/json" -X POST --data "{\"fields\":{\"project\":{\"key\":\"COMMON\"},\"summary\":\"Test ChargenNr\",\"description\":\"some description\",\"issuetype\":{\"id\":\"29\"}}}" http://host.xy:port/rest/api/latest/issue/
this works fine to me now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
curl -D- -u sarika:password -X POST --data {"fields": {"project":{ "key": "Im"},"summary": "REST ye merry gentlemen.","description": "Creating of an issue using project keys and issue type names using the REST API","issuetype": {"name": "Bug"}}} -H "Content-Type: application/json" http://localhost:8080/rest/api/2/issue
But I am getting this error, i am not understanding where i am going wrong
curl: (3) [globbing] nested brace in column 10
curl: (6) Could not resolve host: key
curl: (3) [globbing] unmatched close brace/bracket in column 3
curl: (6) Could not resolve host: REST ye merry gentlemen.,description
curl: (6) Could not resolve host: Creating of an issue using project keys and issue type names using the REST API,issuetype
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 4
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
X-AREQUESTID: 793x751x1
X-ASEN: SEN-L8133948
Set-Cookie: JSESSIONID=663D2360E11386DA0D7CC5BD3C24E309; Path=/; HttpOnly
X-Seraph-LoginReason: OK
Set-Cookie: atlassian.xsrf.token=B08B-686I-ATFB-BS3I|e996f4af4997120d8563fe7c1ac88ada11b43dfa|lin; Path=/
X-ASESSIONID: h1fk5w
X-AUSERNAME: sarika
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 15 Jul 2016 07:43:49 GMT
Connection: close
{"errorMessages":["Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@18fd308b; line: 1, column: 3]"]}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's saying your JSON is not structured correctly. I'd check the layout is exactly what you copied from the example doc (it looks like the example data to me, so that's a bit of a guess)
One thing I find useful when using REST is to put the JSON in a more human-readable file and use an editor that can understand JSON and tell you when it's wrong. Curl can be told to read that file instead of the long block of text. For example:
nic reststuff$ cat data.txt { "fields": { "project": { "key": "TIS" }, "summary": "Weekly cleaning up of the engineering lab", "description": "A task for making sure we clean up regularly", "issuetype": { "name": "Task" } } } nic reststuff$ curl -D- -u nic:password -X POST --data @data.txt -H "Content-Type: application/json" http://myjira:8080/rest/api/2/issue/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd start with spelling - summery and descrpition are not Jira fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.