user cant make realation with rest api thingsboard

340 views Asked by At

I have a problem with thingsBoard, I can make a relation in the website with a user account and I tried to relate a device to an asset but when it comes to rest API it gives me a 403 error code. I used swagger UI and I used entity-relation API and I used save relation API for this.

image

1

There are 1 answers

1
Fabio Suarez On

I believe that your problems is that you are not logged to your swagger. In your image, look the exclamation sign inside the red circle, that meaning you didn't set your token on the swagger.

How to get the token: curl --location --request POST 'http://YOUR_IP_ADDRESS/api/auth/login'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--data-raw '{ "username": "YOUR_EMAIL_ADDRESS", "password": "YOUR_PASSWORD" }'

With the token received, go back to the top of the swagger and looking for the "authorize" button. There put your token. When you go back to your operation, you can see that the exclamation sign now is in a blue circle. Try again! Now, your operation should work!!