A basic example for APIFunction[]
is
doubled = APIFunction[{"x" -> "Real"}, #x*2&]; doubled["x"->6.5]
which shows the output 13.
in a notebook. When I deploy this using
CloudDeploy[doubled]
I get back a CloudObject
.
Calling it in a browser like "https://www.wolframcloud.com/obj/707...?x=6.5" will return 13.
as a response.
Now I tried the same with an association, but cannot get it to work:
content = APIFunction[Association["lampstatus"-> "on", "temp" -> 37.2][#x]&];
content["x"->"lampstatus"]
will give the expected output on
, but in the browser "https://www.wolframcloud.com/obj/707...?x=lampstatus" will not output this single value.
Thanks for any help...
Of course this gave no better results (questions/159215):
URLExecute[content, {"x" -> "lampstatus"}]
or
URLBuild[First@content, {"x" -> "lampstatus"}] // Echo // SystemOpen
APIFunction[Association[...]]
is supported? Onlylist
can be given as parameters. Association is needed when you apply those parameters likeAPIFunction[....][<|..|>]
. $\endgroup$list
is a valid parameter... $\endgroup$content = APIFunction[{"x"->"String"},<|"lampstatus"-> "on", "temp" -> 37.2|>[#x]&];
$\endgroup$