Clockify API - Wrong Date Format?

Hi,

I’m trying to create a new expense entry with python and the Clockify API and get the following error:

‘{“message”:“createExpense.request.date: You entered invalid value for field : [date]. Values that represent [date] can't be null and can't be empty. Please make sure that the [date] date is not greater than 9999-12-31 and not less than 0001-01-01. Ensure that the [date] date is in following format: \“yyyy-MM-ddThh:mm:ssZ\” Example: 2018-11-29T13:00:46Z.”,“code”:501}’

and here ist the code:

api_key="XXX"

header = {'Content-Type': 'multipart/form-data; boundary=ebf9f03029db4c2799ae16b5428b06bd', 'x-api-key': api_key}

expense = {
  "userId": "XXX",
  "date": "2022-05-26T18:17:01.123Z",
  "projectId": "XXX",
  "categoryId": "XXX",
  "notes": "My note",
  "amount": "2.0",
  "billable": "true",
  "file": "(binary)",
}

z = requests.post('https://api.clockify.me/api/workspaces/XXXXXXXXXX/expenses', data=expense, headers=header)
print(z.content)

I don’t know why, because the Date Format is right. It doesn’t work even with the suggested format in the message “2018-11-29T13:00:46Z”

Can anyone help?

Thanks

Hi @schimmi6

Our Dev team has advised that you would have to change your headers, since once you’re using python, there is no need to include ‘content type’ field.

You can find more about this here.

Here is also an example of your request:

Hope this helps, cheers!

Hi, thanks for the answer.

Now I get the following error:

{"message":"Content type \'application/x-www-form-urlencoded\' not supported","code":3000}

Yes, I know this thread on stackoverflow, and that’s where I got the “idea” for the content type field…

Hi @schimmi6, thanks for getting back to us.

I believe we would need to troubleshoot this further with you, therefore please reach out to us at support@clockify.me so we can see what might be the issue here.

Cheers!