We tried our best to test REST API on postman, but it is showing 401 unauthorized error. Please guide me to resolve this, also guide me the right steps:
Where did you get the bearer token from?
I recommend, especially when using apps like postman, to setup an oAuth2 flow.
Similar to what you tried here:
1 Like
Thank you Martin,
I just follow the steps and able to get âAccess Tokenâ
- Open Postman and create a new request.
- Set the request method zo âPOSTâ.
- Set the request URL to: https://{your-openremote-url}/auth/realms/{realm}/protocol/openid-connect/token
- In the request body, select the
x-www-form-urlencoded
option and enter the following parameters:
grant_type
:client_credentials
client_id
: {name-of-service-user}
client_secret
: {generated-secret-of-service-user} - Click âSendâ to get response with access token
For getting information about a specific asset I did the following:
- Create new request in Postman.
- Set the request method to âGETâ.
- Set the request URL to: https://{your-openremote-url}/api/master/asset/{assetID} (see also OpenRemote Manager HTTP API Swagger UI )
- Add an
Authorization
header to the request and set the value toBearer {access_token}
, where{access_token}
is the access token obtained in the previous step. - Click âSendâ button to send the request to OpenRemote.
But here I am getting error as below attached: is the way I wrote âBearerâ and after that access token is right?