i might struggle a bit to understand how to receive data from openremote via REST API. I receive data on openremote via MQTT and want to receive the data on my app via REST API from openremote.
I had a look at the User Guide on Github for APIs but couldn’t find anything specific for my case. Also searching the forum didn’t help me to understand how it works.
Do i need to create an additional Asset? I also found the swagger OpenRemote Manager REST API. Do i just call the MQTT Agent here? which URL do i have to use here?
Sorry for that many questions, i just feel like i can’t find the solution here (first IoT project here and happy i got the MQTT running)
To be able to use it you will need to create a service user with permissions to read and/or write.
It’s hard to figure out exactly what you’re trying to do but sounds like you want to use a HTTP client to make requests to OpenRemote via the HTTP API (to retrieve attribute values?).
HTTP is not the right tool for this purpose being a request-response protocol, websocket or MQTT would be more preferable as they are publish-subscribe so you could listen for updates to the attribute(s) rather than using HTTP polling.
thanks for your quick reply and sorry for mine being so late. You’re right with your assumption on how i want to use it. I’ll give i a try to explain it a bit more.
I’m receiving sensor data from a database via MQTT on openremote. The plan for now is to visualize the data on OpenRemote and send it further to an App. The App would only do GET requests to receive the data and in OpenRemote a rule would update the values for the http requests (this was my idea so far).
As it’s an university project for my studies, my supervisor told me i should look for different protocols to use. But if it’s not possible, i’ll stick to MQTT
So i got it right that there is no possibility to access the sensor data on OpenRemote via HTTP API on my App? I had a deeper look at the swagger documentation but i’m not sure if this is the key to what i’m planning .
HTTP is just not the protocol for publish subscribe type data.
If you want to explore other protocols then there is the websocket API which is for publish subscribe type requests and you should find some explanation in the wiki.
My idea is not to publish data to via HTTP. In my App i want to receive a value as soon as a trigger is hit, so i don’t need to listen to the server. I thought HTTP as request-response protocol would be the right protocol for this scenario.
As i’m trying to get into the demo documentation on Swagger, i’m quite sure that i need to authorize before being able to make requests as i’m getting response errors for forbidden access.
So when i authorize on this
and log in with my admin account i receive this error even if i enable cookies for everything.
I also receive an internal error when i’m trying the Authenticator for my Account (not sure if this needs to be done in advance)
Is there anything i’m missing and that needs to be enabled in ManagerUI?
To create/update users you need to be logged in as a user with those roles for example the default admin user.
Note that due to limitations in swagger UI you can only use the swagger UI for the master realm (i.e. you cannot configure the token URI that swagger uses in order to authorise a different realm).
Request Response protocols like HTTP work well when you are requesting something but what you describe as “receive a value as soon as a trigger is hit” doesn’t fit with this model and has traditionally been handled using some form of long polling which is in-efficient. Hence publish subscribe type protocols are a much better fit for this.
I just realized that i changed the password for admin and due to that i couldn’t see users anymore. As i changed it back i was able to see all of it again.
When i’m trying to authorize the user (created in admin mode) on swagger (localhost) i receive “Invalid parameter: redirect_uri”. User has access to everything and exists otherwise i receive the message “Client not found”.
so i’m able to authorize via the default client_id/secret but i still receive 403: Forbidden access. I think it’s due to the missing authorization header/ token that i can’t request (still receiving internal server error while trying to request the token as in the post above).
How can i receive the token if i can’t use the endpoint?
I need the token for the Header to authorize my request i guess
You should be able to authenticate and also make requests using the Swagger UI.
As for using some other client then the service user approach is the correct way to go and to then ensure that the created service user is assigned the appropriate permissions.
You should then be able to follow the client_credentials OAuth2.0 flow to get an access token and to then use this in your HTTP requests Authorization header as a Bearer token.
we have managed to get the token using a newly created user and secret from open remote, however we are receiving 403 forbidden while using the returned token.
Note : we also receiving the below error in the manager:emote.container.web.WebServiceExceptions : Web service exception in ‘RESTEasy Role Security’ for ‘POST http://57.217.164.84:8443/provisioning’, root cause: javax.ws.rs.ForbiddenException: Only super admin can create provisioning configurations
So you have managed to authenticate successfully; the 403 indicates an authorisation issue and that is because the endpoint you are calling is only intended to be used by super users; with the latest manager docker image you should be able to add the super user realm role to a user. Long term we will add a dedicated role for device provisioning CRUD operations.