CURL - Unable to retrieve device shadow using curl - ANSWER You must use the REST API master key

CURL - Unable to retrieve device shadow using curl

I have looked at the original post “Unable to retrieve device shadow using curl”

I am of course substituting the real keys for PUBLIC_KEY and DEVICE_KEY

I have tried:

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_tokenPUBLIC_KEY

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_tokenDEVICE_KEY

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_token"PUBLIC_KEY"

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_token"DEVICE_KEY"

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_token’PUBLIC_KEY’

curl https://mdash.net/api/v2/devices/device2/rpc/RPC.List?access_token’DEVICE_KEY’

What I get back is:
{“message”:“Unauthorized”}

My ACL is as follows:
{
“shadow_read”: “.”,
“shadow_write”: “.”,
“rpc”: “.*”,
“public_key”: PUBLIC_KEY,
“data_read”: {},
“data_write”: {}
}

What am I doing wrong?

Any help would be greatly appreciated!

@bclough - If you’re trying to get the device object, this is what you want to use:

curl --request GET
–url 'https://mdash.net/api/v2/m/device?access_token=PUBLIC_KEY
–header ‘Accept: application/json’
–header ‘content-type: application/json’

Official definition here.

Give that a shot and let us know how it goes.

-AD

Thanks Autodog

My problem is I was using the wrong key. You must use the “REST API master key”

Yes, the key usage depends on the type of endpoint you’re trying to access:

  • The Management REST API endpoints require the master key
  • The Customer REST API device endpoints require a device public key
  • The Customer REST API customer endpoints require a customer key