Please can someone confirm how to pass a parameter into the API URL using powershell.
I create a new Jira ticket via the API and store the response ticket ID as a powershell parameter called $jiraticketid
I then try add comment to the newly created ticket within the same powershell script, adding the ticket ID parameter into the API URL shown below in bold:
$body = "
n{
`n `"body`": `"This is a test comment within powershell`"
`n }"
$response = Invoke-RestMethod 'https://EXAMPLE.atlassian.net/rest/api/2/issue/{$jiraticketid}/comment' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
This keeps giving me a (400) bad request error message, do I need to pass the parameter as a header?
Thanks in advance Andy.
Hi!
Are you sure your body is json object?
If I were you I will use the next module to reduce the expected bugs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Some quick troubleshooting could be to just start with
$url = "https://EXAMPLE.atlassian.net/rest/api/issue/' + $jiraticketid + '/comment"
$response = Invoke-RestMethod $url -Method 'POST' -Headers $headers -Body $body
Now using the project that @Gonchik Tsymzhitov mentions could be good alternative but since it's a basic call this could be a quick win :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your time Dirk, still couldn't get this working using your example. I've installed Jira PS and it's working like a dream!
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.