Using API To Claim Device - Always Get Errors: "data.deviceID is empty"?

Hello, I am using the API to view specific device ID’s, and to claim devic ID’s. I can view specific device ID’s just fine using this:

var client = new RestClient(“https://api.particle.io/v1/devices/” + _photonSerialNumber + “?access_token=” + _particleAPIToken);
var request = new RestRequest(Method.GET);

request.AddHeader(“Accept”, “application/json;”);
request.AddHeader(“Content-Type”, “application/json;”);

IRestResponse response = client.Execute(request);

This works just fine. However, when I try to claim devices, I always get the error message “data.deviceID is empty”:

var client = new RestClient(“https://api.particle.io/v1/devices?id=” + _photonSerialNumber + “&access_token=” + _particleAPIToken);
var request = new RestRequest(Method.POST);

request.AddHeader(“Accept”, “application/json;”);
request.AddHeader(“Content-Type”, “application/json;”);

IRestResponse response = client.Execute(request);

Notice the error is references “deviceID” and not “id”. So I tried “deviceID” as well. I’ve tried adding “id”/“deviceID” as parameters in the body, and I get the same error messages. When I put the access_token in the body instead as a query string I get error that its an invalid access_token… so the access_token only works as a query string apparently.

Any idea what might be my problem? Thanks and any help is greatly appreciated!

Checking back in on this. Does anyone have any ideas?

Hi @Mahonroy,

Sorry to hear you’re having troubles.

I went ahead and just tested this endpoint in cURL with the following command to confirm it’s operating as intended:

curl -X POST https://api.particle.io/v1/devices \
      -d id=<ID_REMOVED> \
      -d access_token=<TOKEN_REMOVED>

To double check, you are providing the device’s ID and not serial number, correct?

It’s also entirely possible there may actually be an issue with your access token. Where is it you are sourcing your access token from?

I got it to work last night. Putting both the id and access_token in the body, or both in the URL as a query string will not work. However… putting the access_token in the URL as a query string, and id in the body actually works for some reason. But, vice versa does not work - e.g. id in query string, access_token in data. Definitely odd. All my other Particle API integrations work, this is the only one that seems to have some issues on the back end?