Unable to download PTO information using API

Hi,

Quite recently - this week, I believe - I started to receive error code 400 during attempts to download the PTO information through API. A funny thing is, I’m using the same code, I have been using succesfully for months - and the same, which works fine when obtaining other information from Clockify API.

Sample data I use is here:

URL: https://pto.api.clockify.me/v1/workspaces/639aec4fa62a155b60b2634f/requests
headers: {'Content-Type': 'application/json', 'X-Api-Key': 'MYAPIKEY'}
postdata: {'start': '2023-06-01T00:00:00.000Z', 'end': '2023-06-29T23:59:59.999Z', 'statuses': ['ALL'], 'users': ['63760f12fa3c102460a43f12'], 'page': 1, 'pageSize': '1000'}

The message which is returned varies, and is either

“message”:“Cannot invoke "java.lang.Integer.intValue()" because "pageSize" is null”,“status”:“BAD_REQUEST”

or

“message”:null,“status”:“BAD_REQUEST”

Has anyone experienced similar issues?

Thank you very much in advance for your help and suggestions.


Best regards,

Jan.

Hi Jan,

Can you please send us a request body from this particular request to support@clockify.me so we can investigate the issue further?

Cheers,

Hi Nikola,

Thank you very much for your response.

I posted the information on the forum because a response from the support team seemed to be delayed – and I hoped to receive hints from the community instead. The request body is included in my original post as “postdata” – apparently a misnomer.

In the meantime however, the case was solved in collaboration with the support team.

It seems that the root of the problem was that earlier the PTO API had accepted a pageSize keyword, while now it must be spelled as page-size.

So

curl --location ‘https://pto.api.clockify.me/v1/workspaces/639aec4fa62a155b60b2634f/requests’ \
–header ‘X-Api-Key: MYAPIKEY’ \
–header ‘Content-Type: application/json’ \
–data ‘{ “start”: “2023-06-01T00:00:00.000Z”, “end”: “2023-06-30T23:59:59.999Z”, “page”: 1, “page-size”: 1000, “statuses”: [“ALL”], “users”: [“63760ee5fa3c102460a43925”] }’

works, while:

curl --location ‘https://pto.api.clockify.me/v1/workspaces/639aec4fa62a155b60b2634f/requests’ \
–header ‘X-Api-Key: MYAPIKEY’ \
–header ‘Content-Type: application/json’ \
–data ‘{ “start”: “2023-06-01T00:00:00.000Z”, “end”: “2023-06-30T23:59:59.999Z”, “page”: 1, “pageSize”: 1000, “statuses”: [“ALL”], “users”: [“63760ee5fa3c102460a43925”] }’

(which I used in my code, based on the pre-update documentation) does not.

Besides, the error message still complained about the missing pageSize parameter and returned two different responses, which was confusing for me.

Anyway, from my perspective the case is solved now.

Thank you very much for your help.