awork-io / awork

The awork Github repo supports you with awork integration and api questions. Here you can find links to further documentation, a FAQ with the most frequently asked questions and great code examples to get started even faster.
https://www.awork.com
11 stars 0 forks source link

API, projects: 'company:id' gets lost when a project is updated by PUT #128

Closed wwdto closed 1 year ago

wwdto commented 1 year ago

What happened?

API: companyid gets lost when updating name or status of a project

method: PUT endpoint: https://api.awork.io/api/v1/projects/f2e48562-b26c-4d65-9360-4c04c4d03fd9 payload: {"isbillable": true,"name": "99031013 - DTO1013_Test, ob Kunde verlinkt bleibt"}

https://github.com/awork-io/awork/assets/90595629/349f82ce-85af-4865-87ac-110246636411

What is the trace id of the call?

trace-id: 650cbf77526b14247351232464e42d01

trace-id: 7c8de58060f8aedab16d319ab225c743

https://github.com/awork-io/awork/assets/90595629/fc92e6c7-7f5f-4b2f-8928-2d5890e83a68

Relevant error responses

No response

wwdto commented 1 year ago

Additions:

So we have no idea how to fix these missing connection to company.id for more than 70 projects?

Payload-examples or updating a project:

  1. Version: { "isbillable": true, "name": "99031013 - DTO1013_Test, ob Kunde verlinkt bleibt", "company": { "id": "68dd2010-1764-ed11-ade6-cc60c8b6713c" } }

2.Version: { "isbillable": true, "name": "99031013 - DTO1013_Test, ob Kunde verlinkt bleibt", "company".id": "68dd2010-1764-ed11-ade6-cc60c8b6713c" }

nilzzzzzz commented 1 year ago

What happened?

API: companyid gets lost when updating name or status of a project

method: PUT endpoint: https://api.awork.io/api/v1/projects/f2e48562-b26c-4d65-9360-4c04c4d03fd9 payload: {"isbillable": true,"name": "99031013 - DTO1013_Test, ob Kunde verlinkt bleibt"}

Update_Project.1.2.mov

What is the trace id of the call?

trace-id: 650cbf77526b14247351232464e42d01

trace-id: 7c8de58060f8aedab16d319ab225c743

Update_project_postman.2.mov

Relevant error responses

No response

Hello @wwdto, it's crucial to understand the difference in how HTTP verbs such as PUT and POST behave. The PUT HTTP verb is idempotent and meant for complete replacement of a resource. Therefore, when you use PUT, it's expected that you provide all the fields of the resource.

Here's why: If you're using PUT and you don't provide a value for a particular field like CompanyId, the request assumes that you want to update the existing value to 'null'. That's because PUT is designed to replace the entire state of the identified resource with the state defined in the request body, not just modify some parts of it. We unfortunately do not support PATCH so you always need to get the whole entity and then send all fields which you received before.

Best regards

Nils