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$
    – b3m2a1
    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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.