Start a new topic
Solved

Cant update Asset over API - 422 Error Unprocessable Entity

Hey, 

so I've been trying to change some fields over your API, but it seems no matter what I send as a body I always get '422 Error: Unprocessable Entity'. Other API calls seems to work fine (at least these that I've tested). Any way to work this out? Or am I doing something wrong? I've been doing this according to https://api.freshservice.com/#update_asset 


Please help :(


I'm using Basic Auth (using admin token - blurred on screenshots) - is there a chance that this token is good for viewing assets but not for modifying them? Or I'd get some other response like 401: Unauthorised?)


Im attaching screenshots from created requests in Postman (GET that works and PUT that should update asset but doesn't). I'll provide cURL command if needed.

Also, I've seen you started rolling out API v2, but seems like v2 doesn't provide Update method yet :(

I also faced the same issue in Postman, clearing cookies will resolve the issue.

The below curl command works, please check if you miss anything 

curl -u user_name:password -H "Content-Type: application/json" -d '{"cmdb_config_item": {"asset_tag": "xyz", "name" : "mandatory"}}' -X PUT https://demo.freshservice.com/cmdb/items/<asset display_id>.json


1 person likes this

For some reason this actually solved the problem :D thanks! 


Now I see that when updating asset `name` field is mandatory in request body. Is there a reason for this? I wanted to update asset based on `display_id`, instead now I need to GET asset using `display_id` to fetch current `name` and then PUT to actually update this asset. Seems weird and feels like traffic waste :/ 


Any reason behind that?


Michal,


Looks like an issue in how the asset is updated when using the API. We'll check this and get back to you. Btw, API V2 for all asset operations is being worked upon. More details here: https://support.freshservice.com/support/discussions/topics/322755


Best,

Sid


1 person likes this
Login or Signup to post a comment
JS Bin