Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira v2 rest api examples.

Serphentos
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 27, 2021

Hello. 

I used Jira api v2 to create issue and assignee uer for it. Something like what:

curl -D- -u 'user;user' -X POST --data '{"fields":{"project":{"key":"TEST"}, "summary":"TEST", "description":"Test Started", "assignee":{"name":"charlie"}, "issuetype":{"name":"Task"}}}' -H "Content-Type:application/json" https://myjira,test:443/rest/api/2/issue/ -k 
After what i want to move issue to closed via transitions:
curl -D- -u 'user:user: x' -X POST https://myjira.test:443/rest/api/2/issue/TEST-9312/transitions?expand=transitions.fields -k --data '{"transition":{"id":"291"}}'
And receive the error: HTTP/1.1 415
But 
this one works fine.
curl --request POST --url 'https://myjira.test:443/rest/api/2/issue/TEST-9312/transitions?expand=transitions.fields' --user 'user:user' --header 'Accept: application/json' --header 'Content-Type: application/json' --data '{"transition":{"id":"291"}}' -k

I don't understand why i get this errors and why patterns so different.

Thanks

1 answer

0 votes
Thomas Deiler
Community Champion
October 15, 2021

Dear @Serphentos ,

welcome to the community!

In your first call, you did not set the custom headers

Accept: application/json

Content-Type: application/json

Sometimes when you get a 

XSRF check failed

you need to set the

User-Agent: x

header, too. HTTP_CODE 415 is in most cases an indicator for missing header information.

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events