Forums

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

Powershell RestAPI 405 error adding a new version

Antonio Giusto
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 7, 2022

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
Antonio Giusto
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 8, 2022

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

Pranav Lonsane August 22, 2023

Hi @Antonio Giusto 
I am trying the same using below url still getting 405. Can you please help me out?


https://pranavl.atlassian.net/rest/api/2/issue/KAN-2

Suggest an answer

Log in or Sign up to answer