HTTP JSON Retriever - Set point gives error on save.
-
I have define a HTTP JSON Retriever Source and added a Set Point URL. This saves OK.
Data point definition saves and validates fine.
However, The when the "Settable" box and Set Point Name are configured saving the point returns an error.Internal Server Error — java.lang.ClassCastException: class com.serotonin.m2m2.http.vo.HttpJsonRetrieverDataSourceVO cannot be cast to class com.serotonin.m2m2.http.vo.HttpRetrieverDataSourceVO (com.serotonin.m2m2.http.vo.HttpJsonRetrieverDataSourceVO and com.serotonin.m2m2.http.vo.HttpRetrieverDataSourceVO are in unnamed module of loader java.net.URLClassLoader @560513ce)
Any advice? Documentation is a little thin on this/
Version 3.7.1
A previous similar question was not really answered:
Re: How to set a value using http -
You will find more information if you look under the normal HTTP Receiver and Retriever DataSources. The JSON variants merely extend these.
I think personally there has been some mix up with how these are supposed to work and displayed. The set point name is for a GET request to pull data from a parameter - especially from mango http publishers. I personally wouldn't use this as the JSON will be in the body of a post. I think this is where the same interface is being used for two different things, hence the mixup and lack of info. Remove that and stick to just the JSON pointer and the path for the timestamp if applicable. The settable will enable you to set point values via the API/dashboard without the need to retrieve data from the post request.Better yet if you can explain what you're trying to achieve I think it is possible for a better solution to be realised.
EDIT:
**Setting values** When setting a value to an HTTP receiver point, the Set point URL deterines where to issue a GET, with the set value encoded in the request's parameter(s). The Set format determines the encoding. If using Legacy set format, this will be a ?name=pointLocator.parameterName&value=setValue sort of query string. If using Publisher set format, the query string will appear as it would from an HTTP publisher: ?pointLocator.parameterName=value@time If the point is not configured to include timestamp, the @time portion is omitted. The data source's date format determines how the date is encoded.
Upon closer inspection, the error could likely be due to not setting your timestamp format type for the set point url
Fox
-
Thanks Fox.
Using normal HTTP Retriever the "Settable" works. Just not the with the JSON variant.But even if there is a fix for the JSON version, I suspect that the HTTP JSON Retriever will, like the normal one, do a SET with a GET method Query. While there is no official method to do a HTTP "set", a POST or PUT would be a lot more appropriate than a GET.
{"method":"GET","path":"/api","query":{"name":"airtemp","value":"25"},"headers":{"x-forwarded-for":"103.30.92.123","x-forwarded-proto":"http","x-forwarded-port":"80","host":"80a86fbe836e421a7363a19aee8ef3d8.m.pipedream.net","x-amzn-trace-id":"Root=1-5ec232c0-a1ad0510c55a8440ee963140","user-agent":"Apache-HttpClient/4.5.5 (Java/11.0.5-ea)","accept-encoding":"gzip,deflate"}}
I will probably write a script that retrieves and sets points through the devices REST API.
Your edit relates to HTTP receiver, not the retriever.
-
Your edit relates to HTTP receiver, not the retriever.
More that the help data is all over the place, the retriever and receiver overlap, the receiver has the information regarding the point url info. not the retriever.
I will probably write a script that retrieves and sets points through the devices REST API.
Usually the more sensible option.
Fox