Update
I originally thought there was something wrong with my usage of URLRead. But then I switched from my Mathematica instance on Ubuntu 17.10 to an instance on OS X 10.11 and it works fine on OS X.
So... Is this an issue with my installation? Or a bug in Mathematica on Linux?
In addition to the problem below, another (most likely related) issue is with URLSubmit
.
URLSubmit["http://www.wolfram.com",
HandlerFunctions -> <|"TaskFinished" -> Print|>]
This gives the following error.
Failure["URLSubmitFailure",
Association[
"MessageTemplate" :> MessageName[URLSubmit, "invak"],
"MessageParameters" -> {
Association["TaskFinished" -> Print]
}
]
]
Original
I have a rest call that I'm using to talk to an Elasticsearch instance that looks like this with cURL.
curl -XGET "http://elastic00.example.com:9200/test-index/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"_id": "AWDd8gqhdJ9xvhUtDICa"
}
}
}'
I can use this with no problems if I run it as an external call from Mathematica.
RunProcess[{"curl",
"-XGET", "http://elastic00.example.com:9200/test-index/_search",
"-H", "Content-Type: application/json",
"-d", "{\"query\":{\"match\":{\"_id\":\"AWDd8gqhdJ9xvhUtDICa\"}}}"
}, "StandardOutput"]
But when I use HTTPRequest
with URLRead
it doesn't work.
req = HTTPRequest[
URLBuild[<|
"Scheme" -> "http",
"Domain" -> "elastic00.example.com",
"Port" -> 9200,
"Path" -> {"test-index", "_search"}|>],
<|
"ContentType" -> "application/json",
"Body" -> ExportString[{"query" -> {"match" -> {"_id" -> "AWDd8gqhdJ9xvhUtDICa"}}}, "JSON"]
|>
]
URLRead[req]
I get an error saying that it is an InvalidLocation
Failure["InvalidLocation",
Association[
"MessageTemplate" -> "Specified request is invalid",
"MessageParameters" -> Association[]]]
ping
can't resolve it. $\endgroup$URLSubmit
example at the top. It's the first example in the the documentation for that function. $\endgroup$