Message Boards Message Boards

2 Replies
1 Total Likes
View groups...
Share this post:

Strange APIFunction / Interpreter Behaviour, Possible Bug

Posted 9 years ago

I've been using Mathematica for a few years, and today decided to have a first play with the Wolfram Cloud, to get a feel for how to deploy a function. I set up a very basic function that, when called via its url with the correct parameters, should interpret the argument as a Wolfram Language expression, and return it:


When called, this mainly seems to work, returning an association with the evaluated expression, e.g[x]/Cos[x]


<|"p" -> Tan[x]|>

as I would expect from Mathematica. Similarly, attaching "p=Cos[Pi]" to the url returns <|"p"-> -1|>, for example.

But there seems to be a bug where "+" is interpreted as "*". So calling


<|"p" -> 6|>

for example.

I have tried this with quite a few expressions, both in Firefox on a thin client PC, and Chrome on my Android phone, and the behaviour is consistent. However, calling the url with "p=Plus[2,3]", for example, returns the correct result. Also using


in the cloud notebook returns


as expected. Could this be a bug with the way "+" is interpreted when in an url, or am I doing something daft?

POSTED BY: Robert Ferguson
2 Replies

Thanks very much for your explanation Kuba, that's given me something to work on.

POSTED BY: Robert Ferguson

There are some special symbols in urls world, like ?, +, % and so on.

You can't use them explicitly but you can use dedicated functions to create a valid URL:

cloudobject =    CloudDeploy @ APIFunction[{"p" -> "Expression"}, # &, "WL"]

SystemOpen @ URLBuild[ cloudobject, {"p" -> "2+3"}]

If you want to be able to write url by hand, then you have to know how to do this replacements. Or you can use FullForm of the expression:


POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract