How to set a value using http
-
Hi,
Just started to use Mango. I have not been able yet to find an example or explanation on how to configure a datapoint so it can be set from the dashboard using a URL like e.g. http://localhost/settemp.php?value=HERE I WOULD EXPECT THE VALUE ENTERED ON THE DASHBOARD.
Everything I tried end up in a casting error after pressing the save button.Thanks,
Marc
-
Hi @MarcBudie
Welcome to the forum. You can activate swagger in your env.properties file. As in the forum: https://forum.infiniteautomation.com/topic/2380/mangoapi-is-there-any-documentation-on-how-to-use-this-module
I dont believe that there is a way to set a point as you describe using a query string. You could use the HTTP receiver and run a script on it to set your point.
Could you maybe give more information on why you would want to do this? So we can advise better -
@craigweb That is what I mean. So I would like to setup a datpoint which can also be set. But it is not clear to me what to configure where. set point URL and/or set point name.
-
Hi MarcBudie,
I just updated the thread Craig linked to so that it's swagger URL also includes detail that as of Core 3.5 swagger moved to /swagger-ui.html if enabled before starting Mango.
I am going to assume that you are writing your own dashboard from scratch, since a few of the angular components are capable of setting values to the point. But, there is also the HTTP Receiver (and JSON receiver), which would be the simplest was to get values into a data point via HTTP POST or GET. And there are /rest/v1/point-values endpoints that support using PUT to set values to one or more points, which you could explore via swagger.
-
@phildunlap Hi, I would like to use the HTTP receiver. I already did that to collect datapoint. But it is not clear how to use that to set datapoints.
-
You would use a Point Link, or you could use a script or meta point if you need to parse apart the value (they have the
.set()
function for context points, or in a meta point you could return the extracted value to store it in the meta point). -
Also note that you may want to create IP whitelist entries on the data source if any important control is going through an HTTP Receiver, as that is not authenticated. You can also white list devices, and then include parameters for that device as specified in the contextual help for the HTTP receiver data sources.
-
@phildunlap I now got it working using http retriever. Configured the url in the data source and just put a name in set point name field in the data point. However, doing the same using a json retriever I get a casting error. Something is different between these two?
-
Yeah, the JSON receiver has two receive types, one for legacy support and one for the more intuitive way it works. The legacy (Parameter receive type) use is presented here: https://forum.infiniteautomation.com/topic/2642/how-to-use-http-json-receiever-to-receive-the-data-with-is-by-json-format
For the more intuitive format, where the whole POST body is JSON for instance and the content type is application/json, then the "HTTP parameter name" field needs to be a JSON pointer. Someone linked in this thread to a tool to help craft JSON pointers: https://forum.infiniteautomation.com/topic/3029/json-retriever-documentation-missing/5
But in short it's like a path, like
/
on an alphanumeric point should catch the whole JSON object.
/key
should get whatever is at{"key":...}
/keyToArray/5
should get the fifth index of the array at{"keyToArray":[...]}