Can't unlock device firmware via REST API. Getting 500 error - Cast to Number failed for value "NaN"

I'm trying to unlock the locked firmware version for a device in my Electron product via a windows batch file.

here is what I have tried so far, and the responses:

Request 1 as per the Particle Cloud API Reference on unlocking product device firmware

curl -X PUT https://api.particle.io/v1/products/myproduct/devices/mydeviceID^
-d desired_firmware_version=null ^
-d flash=true ^
-d access_token=myaccesstoken^
-k

Request 2 (with quotes)

curl -X PUT https://api.particle.io/v1/products/myproduct/devices/mydeviceID^
-d desired_firmware_version="null" ^
-d flash=true ^
-d access_token=myaccesstoken^
-k

Responses (both the same)

{"ok":false,"code":500,"errors":["Cast to Number failed for value \"NaN\" (type number) at path \"version\" for model \"ProductFirmware\""]}

Is this a bug in the Particle cloud API?

I've never figured out how to do it from curl using -d. You can do it using curl by creating a JSON payload and using content-type: text/json.

The problem is that when passing parameters with -d they're passed as strings by curl. When the API ingests them, it will not coerce the string into the required data type. This will affect desired_firmware_version (a number, and the error you are getting) and also flash which is a boolean.

I think the example in the docs is wrong because the API used to coerce the data types but it stopped doing that many years ago and I never fixed the example.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.