Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,998
Community Members
 
Community Events
168
Community Groups

Powershell RestAPI 405 error adding a new version

Hi,

I'm quite new using the Jira Rest API. I'm trying to improve our CI/CD processes integrating as many things(Jira activities) as possible in our pipeline.

I didn't have big problem with the GET method to retrive the information but on the other hand, I 'm encountering a lot of problems if I want to create something on Jira through a -Rest API using Powershell scripts.

Using this kind of script to add a new version in the Jira Releases section:

 

$accessToken = “token_copied_from_Jira_user_Configuration”
$headers = @{Authorization = “Bearer $accessToken”}


$JsonBody = '{
"name": "Tp_Logger_v.X.X.X.XXX",
"archived": false,
"released": false,
"projectId": 11701
}'

$r = Invoke-RestMethod -Headers $headers -Uri 'https://my.jira.server/rest/api/2/project/MYPROJECT_NAME/version/' -Method 'POST' -ContentType 'application/json' -Body $JsonBody

 

this is the answer: 

Invoke-RestMethod : The remote server returned an error: (405) Method Not Allowed.

Also using the Postman software I obtained this:

 

image.png

The strange thing is also that from the postman headers, I can see, in the last row, that the allowed methods are Head, Get and Options!

We have this version:  Jira v8.20.11

THX

BR

 

Antonio

 

 

1 answer

1 accepted

0 votes
Answer accepted

Hi,

at the end, after some experiment I found the error...it was related to the URI i used to generate a new version!

Uri = "https://my.jira.server/rest/api/2/version/"

Using this, the creation is performed correctly!

;-)

 

BR 

Antonio

Suggest an answer

Log in or Sign up to answer