rest API : can't send commands with more than 1 parameter
|
|
---|---|
Hi everyone ! I am currently working on an Android app where I am trying to send a command with the Tango rest API. Until now, I have sent commands with only 0 or 1 parameters and I didn't experience any problem. However, I now need to send a command which has two parameters (and perhaps more later), and the command isn't received by my device server. When I send the command, I receive a failure with the following JSON response :
I send the command with the following uri : "http://<ipAddress>:8844/tango/rest/rc4/hosts/127.0.0.1/20000/devices/SAGA_NG_001/Laser_NG/1/commands/SetVoltage" I don't see in the previous JSON response what is the reason for the command to not be able to be executed. Here are some points that could be importants :
Do you have any idea about the reason of my problem ? Best regards, Nicolas Mienné Thales Group. |
|
|
---|---|
Hi Nicolas, I think you need to send an array when you want multiple input arguments, the same you would do it in pure Tango. What was the problem with 1.22 exactly I wonder? That should work as you said - just replacing the jar Cheers, |
|
|
---|---|
Hi Igor, thank you for your quick answer.
With the old jar, there was only the "rc4" key, so the new jar is successfully launched. However, when I go to "http://<ipAddress>:8844/tango/rest/rc4/hosts", I have the following error, and I have the same issue with "v10" and "v11" :
My TANGO_HOST environment variable is correctly set and I also give the tango host in parameter when I launch the jar. Here is my bat command for launching the jar :
[edit] : in order to run the 1.22 jar, I needed to update my Java Runtime. I installed the OpenJDK11. Cheers, Nicolas |
|
|
---|---|
OK, I see Since some version rest-server does not have any default hosts, so you have to specify one in the URL e.g. "http://<ipAddress>:8844/tango/rest/v11/hosts/localhost;port=20000". Please note port matrix parameter, you need this to specify non-default Tango host port in v1.0&v1.1 or using old syntax "http://<ipAddress>:8844/tango/rest/rc4/hosts/localhost/20000" for rc4 Commands should work when you pass an array. Are you able to execute those commands without REST api? |
|
|
---|---|
Indeed, with the url formatted as you said, I am able to browse my Tango database in v1.1 using Firefox. However it seems that the API I use for the REST communication can't parse the response from the new version. After sending the command, in rc4 I get no error, in v11 I get :com.google.gson.JsonParseException: The JsonDeserializer org.tango.web.server.v10.readers.CommandInOutBodyReader$CommandInOutDeserializer@49413e18 failed to deserialize json object "EnergyMeter" given the type class org.tango.rest.v10.entities.CommandInOutFor your second question : yes, these commands work with non-REST API and also on AtkPanel |
|
|
---|---|
Could you please specify which Tango type is used for the input argument of your command? |
|
|
---|---|
The command takes a DevVarUShortArray. I tried all the following syntaxes to give the parameters, which all result to the same issue : "[0,1]", "0,1", "{0,1}", "(0,1)" |
|
|
---|---|
Hi, I have tested against TangoTest DevVarUShortArray command and it works. Request
Response:
Please note the correct argument - is an object, see device commands |
|
|
---|---|
Thank you for your answer. I couldn't find the documentation of the REST API from the gitHub repository, the link at the end of your message helped me a lot. I have been able to reproduce with a REST client the issue I had in V11 with my Android app (the com.google.gson.JsonParseException) : it is the response we get when "host" and "name" parameters are missing. With the REST client I use for testing, I've been able to succesfully send the command with 2 parameters. I'll let you know if this also works with my Android app, but I'm pretty confident that it will work |
|
|
---|---|
NicolasHi, the documentation is here: https://tango-controls.readthedocs.io/projects/rest-api/en/latest/ All the best, Piotr |