How do I log work for a user via the Jira Cloud REST API?

Benjamin Sutton August 15, 2017

I'm trying to use the REST api in a laravel app, to add worklogs to an issue on my company's Jira Cloud instance.

Whenever I sent the request it gives me an error, "Can not instantiate value of type [simple type, class com.atlassian.jira.issue.fields.rest.json.beans.WorklogJsonBean] from JSON String; no single-String constructor/factory method"

I'm sending the post request to https:my-server.atlassian.net/rest/api/2/issue/ISSUE_ID/worklog with this JSON:

{
    "update":{
        "worklog":{
            "add":{
                "timeSpentSeconds":7200,
                "comment":"Testing pushing worklog using REST API",
                "started":"2017-08-15T14:00:00+00:00"
                }
        }
    }
}

I've also tried sending just:

{
"timeSpentSeconds":7200,
"comment":"Testing pushing worklog using REST API",
"started":"2017-08-15T14:00:00+00:00"
}
 

Can anyone spot what I'm doing wrong?

1 answer

0 votes
somethingblue
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2017

Hi Benjamin,

Here is the example from the Cloud API documentation for updating a worklog:

{
    "comment": "I did some work here.",
    "visibility": {
        "type": "group",
        "value": "jira-developers"
    },
    "started": "2017-08-15T06:53:06.605+0000",
    "timeSpentSeconds": 12000
}

The format you would use for the call is

Try that format and see if you get different results.

Cheers,

Branden

Benjamin Sutton August 17, 2017

Thanks for your answer, but how would I give the worklog ID if I'm trying to create a worklog that doesn't exist yet, not update an existing one?

Tiago Machado
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.
December 19, 2018

Suggest an answer

Log in or Sign up to answer