Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

troubles logging work with jira rest api

kajstewart September 16, 2013

i'm attempting to log work via the api and powershell

making data with:

$datablob = @{timespent="1h 30m";timeSpentSeconds="5400";comment="logging via powershell";started="2013-09-16T11:29:49.743-0700"} | ConvertTo-Json

which generates:

{
"timeSpentSeconds": "5400",
"timespent": "1h 30m",
"started": "2013-09-01T10:30:18.932+0530",
"comment": "logging via powershell"
}

then calling

$result = Invoke-RestMethod -Method POST -Headers $header -Uri http://myjira.company.com/rest/api/2/issue/ISSUE-238/worklog -ContentType application/json -Body $datablob

i keep getting back 400 Bad Request errors.

Anyone see where i've gone wrong?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
kajstewart September 17, 2013

Figured it out. So painful.

I had the capitalization wrong on timeSpent, also timeSpentSeconds isn't needed

correct json block:

{
"timeSpent": "1h 30m",
"started": "2013-09-01T10:30:18.932+0530",
"comment": "logging via powershell"
}

Divanshu Sabharwal April 13, 2018

Can you please post the complete request you were able to create, alongwith the json..The documentations and posts are making me wandering here and there..

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2013

400 means

  • Returned if the input is invalid (e.g. missing required fields, invalid values, and so forth).

Have you tried to follow the exact POST body here (https://docs.atlassian.com/jira/REST/latest/#idp2062512)?

kajstewart September 16, 2013

I haven't yet tried the full JSON body as I understood it wasn't all required, maybe that's wrong.

I'll give it a try but i'm not sure how to know what to set for the self and id elements.

TAGS
AUG Leaders

Atlassian Community Events