1
$\begingroup$

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[]]]
$\endgroup$
  • $\begingroup$ Does the host elastic00.example.com exists at all? Even ping can't resolve it. $\endgroup$ – Alexey Popkov Jan 18 '18 at 17:53
  • $\begingroup$ @AlexeyPopkov No that's just an example url. It's an internal site that unreachable externally anyway so I just used 'example.com'. I was trying to reproduce this with an externally accessible URL but then I found out that it's a Linux specific issue. So I figured it's not that relevant anyway. You can reproduce the issue with the URLSubmit example at the top. It's the first example in the the documentation for that function. $\endgroup$ – Sean Lynch Jan 18 '18 at 17:55
1
$\begingroup$

I think this was an issue with the system not being fully set up after installation. After a reboot of the OS, it works fine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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