4
$\begingroup$

Bug introduced in 11.2 or earlier and persisting through 11.3

[CASE:4007421] confirmed


myApi = CloudDeploy@APIFunction[{"i" -> "Real"}, #i &];

Why does the first call fail?

URLSubmit[myApi, {"i" -> RandomReal[]}
 , HandlerFunctions -> <|"BodyReceived" -> Print|>
 ]
<|Body->{{
    "Success": false,
    "Failure": "The API could not be evaluated because there is no input for fields: \"i\".",
    "Fields": {
        "i": {
            "AllowedExtensions": [
                "json"
            ],
            "AutoSubmitting": false,
            "CodeLanguage": "Automatic",
            "Default": null,
            "Enabled": true,
            "Failure": "This field is required.",
            "Help": null,
            "Hidden": false,
            "Hint": null,
            "Input": null,
            "Interpreter": "Real",
            "Label": "i",
            "Required": true,
            "Type": "Element"
        }
    }
}}|>
URLSubmit[HTTPRequest[First@myApi, <|"Query" -> {"i" -> RandomReal[]}|>]
 , HandlerFunctions -> <|"BodyReceived" -> Print|>
 ]
<|Body->{0.990822}|>

$\endgroup$
1
  • 1
    $\begingroup$ Honestly I think so many of these URL and HTTP handling bugs can be traced to the inconsistencies in having 80000000 different implementations rather than a single function with Options. $\endgroup$ Commented Jan 30, 2018 at 20:48

1 Answer 1

2
$\begingroup$

The bug is confirmed so in order to take it of the unanswered stack I will put a workaround as an answer:

URLSubmit[
  HTTPRequest[First @ myApi, <|"Query" -> {"i" -> RandomReal[]}|>]
, HandlerFunctions -> <|"BodyReceived" -> Print|>
]
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.