Rest API hash errors

While attempting to create a time log via the REST Api I’m getting an error that I can’t sort out.

{"errors":[{"id":"9e57815a39b4d7eef027db7e6bf7c8b6","status":400,"code":103,"title":"API create() invalid/missing entity hash string 'type': {\"id\"=\u003E45}

Following the “create entity” portion of the API docs, I’m sending the following body:
{"user": {"type": "HumanUser", "id": 494},"entity": {"type": "Task", "id": 265445},"project": {"id": 45},"date": "2020-05-13", "duration": 240, "type": "Timelog"}

I’m unsure of what the error is.

2 Likes

Hey Chad!

In your project field, it looks like you’re only supplying the id. Even though we know it’s going to be a project, you still need to supply a type/id pair in order to uniquely identify an entity, so you might want something like:

'project': {'type': 'Project', 'id': 45}

in your body. Give that a shot and let me know how it goes?

2 Likes

First, thank you so much for the reply and explanation. I made the change and am now receiving the following:
{"errors":[{"id":"53234e035f5e97250244d28d8a02b22c","status":400,"code":103,"title":"API create() TimeLog.type doesn't exist.","source":{},"detail":null,"meta":null}]}

That would be because I’m submitting a Time Log via “/entity/time_log”, therefore, the “type: timelog” is not needed. I’m assuming it checks errors on orphans.

1 Like

the extra 'type':'Timelog' is unnecessary, yes. You’re already pointing to the /entity/time_logs endpoint, so there’s no need to specify. :slight_smile:

1 Like

That was causing the “TimeLog.type doesn’t exist” error.

Thank you for your assistance. Working with the API and having no access to the UI has proven challenging.

2 Likes

Ouch, no access to the UI is indeed rough. I hope conditions improve for you!

In the meantime, we’re always here if you get stuck down the road. Take it easy!

2 Likes