CODE 401 Unauthorized? Why?


#1

Hi, can someone help me?

I’ve been working on this little code the whole day, and i can’t figure it out:

I created a new device (generic); get the CIK of the device
I tried to connect the device within 24 hrs, but it’s still disconnected.

I readed a lot on forums for tips but i can figure it out

i added a generic device… Can you help me?

I’m using an arduino uno with non standard ethernet shield, sending this code to m2.exosite.com:80

this is the post, i want to write the value 1 to variable 1:
POST /onep:v1/stack/alias HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK: 47240xxxxxxxxxxxxxxxxxx
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Accept: application/xhtml+xml
Content-Length: 3

1=1

this is the server response
HTTP/1.1 401 Unauthorized
Date: Fri, 29 May 2015 20:29:24 GMT
Content-Length: 27
Server: nginx

HTTP/1.1 401 Unauthorized

Can someone help me to see the light :smile:
Thanks,

Regards,

Reinald Nijboer


#2

First, there is one little problem with your request, your accept header should have a value of application/x-www-form-urlencoded; charset=utf-8 not application/xhtml+xml. The server can’t respond with xhtml. However that isn’t what is causing your 401 issues.

I’m slightly confused about what type of device you’re using. You don’t need to activate a ‘generic’ device (and in fact shouldn’t be able to), so no 24 hour window should apply.

All I can say is make sure you’re copied the CIK completely and if it’s not a generic device make sure it has been activated before using it.


#3

Hi,

Thanks for your answer;
I’ve solved the problem;

I don’t know what i did different this time.
I’ve deleted all the devices and created a new generic device;
copied the new CIK

changed the Accept: string as you instruced me;
put the new instructions into my arduino and everything worked fine…

THanks


#4

Glad to hear it! Let us know if you make something cool with it!