Cumulocity Web SDK - @c8y/client v1021.31.4 (latest)
Detailed explanation of the problem:
Hi, I am currently using the c8y client to develop a custom widget plugin for Cumulocity. In particular, I need to update a managed object, so I am using the update() method of the InventoryService (InventoryService | Cumulocity Web SDK - v1021.31.4).
This method takes only a Partial<IManagedObject> as input, but does not have any reference to the object id. I tried to include the id in the input but the request is not recognized by Cumulocity. In fact, the PUT api to update objects takes the id as path variable (inventory/managedObject/:id).
Error messages / full error message screenshot / log file:
I received a 405 error saying “Method not allowed”. I can see in logs that the endpoint called is PUT inventory/managedObject (without the id).
Is this a bug of the InventoryService or am I doing something wrong?
Question related to a free trial, or to a production (customer) instance?
The id is taken from the object you are passing in.
The types could be improved here as the id is a required attribute of the object you are passing in…
Only guess I have is, that you are not actually passing an asset_id when calling updateAsset.
Can you log the partialUpdateObject object before sending it? Like e.g. this:
Yes, it was a problem with the asset_id that for some reason was passed as undefined to the updateAsset method. Now I can correctly see the id in the partialUpdateObject and the update() method works.