Tempo API: worklogs POST failing with 'User is invalid' (GET is OK)

I'm trying to create a worklog via the Tempo 'worklogs' API, without success.

curl -D- -u myuser:mupassword -X POST -d @worklog.post -H "Content-Type: application/json" 'https://mydomain.atlassian.net/rest/tempo-timesheets/3/worklogs/'

 This is my JSON in the 'worklog.post' file:

{ "issue": 
    {
        "key":"MC-8948"
    },
    "comment":"This is a comment",
    "dateStarted":"2017-11-17T00:00:00.000+1200",
    "timeSpentSeconds":180
}

It fails with 

{"errors":{"worker":"User is invalid","startDate":"Date is invalid"},"errorMessages":[],"reasons":["VALIDATION_FAILED"],"flushedErrorMessages":[]}

I don't believe it's an authentication problem because I can make a GET request without any problem.

I'm under the impression that this is the right documentation, but maybe I'm wrong.

  • How do I define a "worker" that might be valid?
  • How do I define a "startDate", and how is it different from "dateStarted"?

It's all a bit of a mystery!

Thanks heaps.

Kerry
PS: adding ?tempoApiToken to the URL makes no difference

3 answers

1 accepted

0 votes
Answer accepted

See answer above from Susanne Götz

Apparently I was using the wrong end point. Rather than:

https://mydomain.atlassian.net/rest/tempo-timesheets/3/worklogs/

I should've used:

https://api.tempo.io/2/worklogs

Note also that I had success with:

https://mydomain.atlassian.net/rest/api/2/issue/{task}/worklog

More documentation available at https://tempo-io.github.io/tempo-api-docs/#worklogs

@Susanne Barbara Götz - Can you please help here?

 

I too am facing a similar issue and haven't found any leads on it.

Hi Rahul,

Can you please let us know if you are using the Server or the Cloud version. Each version has their own set of API's and require different authentications.

Regards,
Susanne

Good day Susanne,

 

Thank you for the quick response.

 

We use the JIRA DC, here are the details.

 

JIRA:

  • JIRA Software 7.6.9

TEMPO:

  • Tempo Timesheets - 8.6.2 ENABLED
  • System Plugin: Tempo Planning API - 3.10.0 ENABLED
  • System Plugin: Tempo Accounts - 3.4.0 ENABLED
  • System Plugin: Tempo Teams - 3.4.0 ENABLED
  • System Plugin: Tempo Core - 4.5.0 ENABLED
  • System Plugin: Tempo Platform API - 1.4.0 ENABLED
  • System Plugin: Tempo Platform - JIRA - 1.4.0 ENABLED

 

The interesting thing is, it is happening for only one user. There are no complaints from any of the other ~2400 users.

 

 

System.Net.WebException: The remote server returned an unexpected response: (400) BadRequest.

{"errors":{"worker":"User is invalid"},"errorMessages":[],"reasons":["VALIDATION_FAILED"]}

 

 

Regards,

Rahul Savaikar

Hi Rahul,

Can you please create a ticket for this in our Tempo support so we can better follow up on this. 

It might be useful to get some more information about the affected user ( f.x if his username was changed ) and the body you are sending with the request.

Regards,
Susanne

Like 1 person likes this

@Susanne Götz

It might be nice if they could throw some hints back here too, so the next person might be able to get the problem resolved. (I'm using Cloud version, btw)

That said, I worked around the problem by not using the Tempo API at all. I'm instead calling:

 https://mydomain.atlassian.net/rest/api/2/issue/{task}/worklog
Like 1 person likes this

Hi @Kerry Sainsbury

To create a worklog on Cloud using the Tempo API, you will need to use:

POST https://api.tempo.io/2/worklogs

The authorization is done via Bearer Token ( you can find or generate your bearer token in Tempo, Settings, API Integration).

Please take also a look at https://tempo-io.github.io/tempo-api-docs/ for more information.

Regards,
Susanne

Like 1 person likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page

                                                      &nbsp...

264 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you