401 Error using Authentication: Bearer <token>


#1

1) Give a description of the problem
I continue to get a 401 Error after setting up Personal Access Token

2) What is the expected behaviour?
It should bring back this information

image

3) What is happening/not happening?
When I run a test…

image

4) Post a Green Snapshot of the pistonimage

image

5) Attach logs after turning logging level to Full
image

image

REMOVE BELOW AFTER READING
How do I get this to work

In postman it comes back perfect, but I know the issue is either how I am setting up the header or I am missing something else.

Any guidance would be much appreciated.

Thank you.

Jared


#2

You might want to block out your token in the third screenshot

I have never used webcore to call the ST api but for another API I use, the curly brackets need to be sent as text. Try escaping them with \, webcore will treat as an expression otherwise.
Also not sure you need the curl header portion…only authorization and token

Example from one of my pistons
\{ "TOKEN_AUTH" : "{authtoken}" \}
obviously not for the ST api, different headers but you get the idea_


#3

You need to send a header of the form

Authorization: Bearer TOKENUUID

The Authorization: bit is being taken care of by webCoRE so it wants you to tell it the other bit. I usually do it as an expression because I tend to use a variable for the token, but the equivalent as an expression without a variable is

"Bearer TOKENUUID"


#4

That worked - Thank you so much.

Jared


#5

Now I need to find a way to add the labels in as individual devices. the string soming back is naming the device Kitchen Water and Basement Button.

I did a replace of the , with an and thinking it would pick up as two separate devices.

image

global variable is one device while device comes back with two devices

I was testing out string but removed it from the global variable.

Thanks.

Jared


#6

What does the raw returned data look like?


#7

Here is the output

[kitchen water leak sensor, basement button]


#8

Maybe this old post might help.


#9

That worked really well. Thanks for showing me that post.