API Error – Flair

Jrskoler

Can anyone tell me how to fix this error 422 shown in this API call:

verboseTrace: patchObjectAsync> - patch api call with attributes {"data":{"id":"de16ee71-a91d-495c-a33b-948b4fcc4861","type":"hvac-units","attributes":{"temperature":82}}} failed, Error: 422

Comments

Jerome Morignot

Your json is really wrong if you are trying to set the temperature:

{"data":{"type":"structures", "attributes": {"set-point-temperature-c":"27.78"}}}

Jrskoler

Thank you for your help.

The dev is using patchObjectAsync and that is the trace created.

The DTH code is:

asynchttp_v1.patch('patchObjectAsync', params, args)

Jerome Morignot

Sorry but I don't understand your statement?! I used Python for my own needs, the json I had to send to the API to patch the temperature set point is the one I wrote in  my previous message. What's DTH code?! :)

Jrskoler

Sorry, I'll explain.

I am using another developer's Smartthings code.  DTH is an acronym for Device Type Handler.  It's part of the programming structure for utilitizing Smartthings.

The code utilizes the library "asynchttp_v1" whithin which is the procedure (I think that's what one calls it) "patch"

Hence, asynchttp_v1.patch('patchObjectAsync', params, args)

In case you're curious:

https://docs.smartthings.com/en/latest/smartapp-developers-guide/async-http.html?highlight=patch

Jrskoler

Turns out the app will only work with the Flair system in Manual mode.

As soon as I switched it to Manual, the error disappeared and the system responded properly to the commands.

Hope this helps someone, sometime.