9

Bug introduced in V11.0 and persisting through 11.3

[CASE:3981157] confirmed


asso = <|
  "Scheme" -> "http"
, "Domain" -> "www.wolframalpha.com/"
, "ContentType" -> "application/json"
|>;

This is a valid and documented syntax:

HTTPRequest @ asso //InputForm
HTTPRequest[
  <|"Scheme" -> "http", "Domain" -> "www.wolframalpha.com/"|>
, <|"ContentType" -> "application/json"|>
]

but it breaks when one provides options:

HTTPRequest[asso, CharacterEncoding -> Automatic] // InputForm
HTTPRequest[
  <|"Scheme" -> "http", "Domain" -> "www.wolframalpha.com/", "ContentType" -> "application/json"|>
, <||>
, CharacterEncoding -> Automatic
]

So it was not split correctly on url and metadata part. Which will result in malformed request.

Have I missed something?

Kuba
  • 136,707
  • 13
  • 279
  • 740

1 Answers1

3

So before it is fixed one needs to arrange full input with help of e.g. URLBuild:

HTTPRequest[
  URLBuild@asso, asso, CharacterEncoding -> Automatic
] // InputForm
HTTPRequest[
  "http://www.wolframalpha.com//"
, <|..., "ContentType" -> "application/json"|>
, CharacterEncoding -> Automatic
]
Kuba
  • 136,707
  • 13
  • 279
  • 740