12

Here is an approach, not battle tested, YMMV. It depends on the new body_markdown parameter in the SE API responses. From there we can use whatever MD->NB tool we like; there are tons of those out in the wild. Here's the code (we have to do a bit of HTML entity clean up, sadly) ClearAll[mseMarkdown, cleanHTML]; $msefilterMap = <| "questions" -> "!...


9

One needs to be careful and construct the HTTPResponse properly before we ask GenerateHTTPRespone to produce the final thing so that it can be consumed by any HTTP client outside of WL world. The following explicit MIME specification will solve the above problem. res = HTTPResponse[ ExportString[Plot[x, {x, 0, 1}], "PNG"], <|"ContentType" -> "...


9

ExportString JSON produces UTF8 encoded json string, if put as HTTPRequest body it will undergo another encoding unless you prevent it with an option: HTTPRequest[..., CharacterEncoding -> None] It is analogous to the double decoding issue which you address with bodybytes//FromCharacterCode//ImportString. Exchanging JSON via http requests This is very ...


8

I've had luck using the functions WriteRawJSONString and ReadRawJSONString from Developer context. Check out: WriteRawJSONString vs ExportString? HTTPRequest[ "https://httpbin.org/anything", <|Method -> "POST", "Body" -> (<|"textWithDiacritics" -> "àéíóú"|> // Developer`...


6

If you have the ability to CloudDeploy functions, you can do it like so: obj = CloudDeploy[APIFunction[{}, $UserAgentString &], Permissions -> "Public"] Import[First[obj]] "Wolfram HTTPClient 12.2" Make sure to clean up after yourself: DeleteObject[obj] What we are doing here is deploying an API endpoint that simply returns ...


6

It looks like this particular request requires you to set a header or two before it will respond the same way it does in the browser. In particular, it looks like it needs you to set the x-requested-by, Accept, and Referer headers. (I discovered this by simply whack-a-moling the headers to see which will give the correct response). I initially took the URL ...


6

It seems you are trying to profit from DOI Content Negotiation described here. Content negotiation allows a user to request a particular representation of a web resource. DOI resolvers use content negotiation to provide different representations of metadata associated with DOIs. A content negotiated request to a DOI resolver is much like a ...


5

To keep this example self-contained, we will use the HTTP introspection service at https://httpbin.org. This is a very handy site for verifying and debugging HTTP transactions. First we will create a small JPG file: Export["zot.jpg", Image[{{1}}]] Then we will create a multi-part HTTP request that will post that file: $req = HTTPRequest[ "...


4

HTTPRequest[""]["Headers"] {"user-agent" -> "Wolfram HTTPClient 12.3"} or HTTPRequest["www.wolfram.com"] // ExportString[#, "HTTPRequest"] & GET / HTTP/1.1 host: www.wolfram.com user-agent: Wolfram HTTPClient 12.3


4

For what it's worth, the issue is in how ExportString is handling the diacritics. We can see that it botches them, but the function being used under the hood doesn't (<|"textWithDiacritics" -> "àéíóú"|> // ExportString[#, "RawJSON"] &) "{ \"textWithDiacritics\":\"àéíÃ\.b3ú\" }" ...


3

This request works: qry = ExportString[{"query" -> "1 cup of flour"}, "JSON"]; results = URLExecute[ HTTPRequest[ urlRoot, <| Method -> "POST", headers, "Body" -> qry, "ContentType" -> "application/json" |>] ] {"foods" -> {{"...


3

request = HTTPRequest[ URL["https://doi.org/10.1007/s00209-015-1612-7"], <| "Method" -> "GET", "Headers" -> {"Accept" -> "application/x-bibtex"}, "ContentType" -> "application/x-bibtex"|>]; URLRead[request, "Body"] (* @article{Blasiak_2016, doi = {10.1007/s00209-015-1612-7}, url = {https://doi.org/10....


3

Alright, I got into contact with the support for the API, and the problem was resolved on their end. Apparently, it was an error in the routers' networking configuration.


3

The curl request is passing the arguments as a form body, but the Mathematica expression is passing query arguments in the URL. Try changing the request property "Query" to "Body" to match the curl request: req = HTTPRequest[ "https://api.particle.io/v1/devices/" <> id <> "/peek", <|"Method" -> "POST", "Body" -> {"args" -> "...


3

We will generate our own Authorization header, because this API uses a slightly obtuse method. The API uses what's known as "Basic Authentication", which is essentially "Basic " + Base64["username:password"]. Since the password doesn't appear to matter for this API, we can generate our header like so. auth = StringJoin["Basic ", ExportString["MYKEY:", "...


2

As @Kuba had commented, ImportString[#, "HTTPRequest"]& does not turn POST parameters to rules. So the property "FormRules", which FormFunction utilizes, can't be generated. Here is a function to finish this convertion when needed: MakeFormRules[request_HTTPRequest] := With[ { makeFormRules = <| URLQueryDecode@StringTrim@...


2

The problem is with my content hash not matching the AWS calculated hash (as you can see in the response from AWS). I didn't figure out how to get them to match, but I found an option in the AWS documentation to use UNSIGNED-PAYLOAD. So instead of calculating a content hash for the key x-aws-content-sha256, simply assign the value of that key to the literal "...


2

Caveat: I do not have a SalesForce account and have not tried this code against the real site. But it works against the testing site https://httpbin.org/anything. For this example we will create minimal PDF content to be uploaded as the main document: $pdf = ExportString[Image[{{1}}], "PDF"]; The SalesForce API requires us to create metadata for ...


1

curl is different from the built-in Curl. curl is a command-line tool and library for transferring data with URLs. This aks for a Mathematica built-in or a call to the OS command line. For a built-in URLDownload may be the corresponding command. But curl is used to exploration purposes too, so URLRead takes this part. For the evaluation of the response ...


Only top voted, non community-wiki answers of a minimum length are eligible