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

API call to issue/KEY/worklog always fails with 400 or 500, never works

Rudie December 7, 2013

This is literally what I'm sending:

{"timeSpent":"5m","started":"2013-12-08T21:00:01+01:00","comment":"x"}

to issue/KEY/worklog in a POST request.

The response is always 500, with "Internal server error" as error message. Not very useful.

The literal response:

{"errorMessages":["Internal server error"],"errors":{}}

If I try another combination of fields, I get an error 400, which makes sense, because it's a wrong combination of fields. The above should work though.

I'm using OnDemand. I don't have any worklog plugins enabled, just the normal stuff that works in the UI. Most of the API works perfectly.

I would think, whatever the error, the reponse should be more descriptive than a 500, which sounds like it's not my fault. But then what is it?

If I use PUT issue/KEY (with update.worklog) as method to log work, the request is, literally:

{"update":{"worklog":[{"add":{"timeSpent":"5m","started":"2013-12-08T21:00:01+01:00","comment":"x"}}]}}

and the response is a 400 with error message:

"Field 'worklog' cannot be set. It is not on the appropriate screen, or unknown."

Might that be why the first request fails too? I don't want to add the worklog widgets to the resolve and edit screens. Logging work is a separate thing and it does work separately via the UI.

:

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
David Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2013

Ran a quick test and got 500 error like you mentioned. I then examined the data and changed it to this:

{"timeSpent":"5m","started":"2013-12-08T21:00:01.000+0100","comment":"x"}

This seemed to work find. Aka, changed the last portion of your time format from "01+01:00" to "01.000+0100".

You should really get a 400 reponse for invalid input instead of a 500.

David Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2013

ah looks like the invalid response was already reported: https://jira.atlassian.com/browse/JRA-31460

Rudie August 14, 2014

Yes! That does it.

I used ISO 8601 to represent datetime (which is a preset in PHP), but Jira always uses the other. I could've spotted that... Thanks!

terryaney November 13, 2014

I'm having problems as well...slightly different, but posted here in case you have any ideas (I've implemented your 'Date' fix as suggested above). https://answers.atlassian.com/questions/10407898/httpclient-c%23-to-create-work-log-always-returns-500-internal-server-error

0 votes
Jakob Reiter January 31, 2019

Ran into the same problem again in 2019.

This time I get a long system stack:
https://community.atlassian.com/t5/Jira-questions/REST-POST-worklog-on-issue-fails-with-500/qaq-p/904382

@David Chan can this be connected? 

TAGS
AUG Leaders

Atlassian Community Events