You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
It would be nice if microdemic passed along the detailed error messages that the API provides, as opposed to just giving the HTTP error code. For example:
library(microdemic)
library(httr)
# here we only get the HTTP error code
ma_evaluate(
query="invalid-query",
key= Sys.getenv("MAG_KEY")
)
#> Error: Bad Request (HTTP 400)# ...but the server provides more details on why this error occured:out<- POST(
'https://api.labs.cognitive.microsoft.com/academic/v1.0/evaluate',
config= add_headers("Ocp-Apim-Subscription-Key"= Sys.getenv("MAG_KEY")),
body="expr=invalid-query"
)
content(out, "text")
#> No encoding supplied: defaulting to UTF-8.#> [1] "{\"Error\":{\"Code\":\"Bad Argument\",\"Message\":\"Invalid query expression\\r\\nParameter name: expression\"}}"
Created on 2019-01-07 by the reprex package (v0.2.0.9000).
thanks for raising the issue. thanks for offering to PR! Please do use crul instead of httr.
Adding this will need to make sure it's comprehensive, e.g., its possible they don't fail consistently so you can't always look for that json payload on failure. I dont remember if their failure behavior is consistent or not. Please do add tests
It would be nice if
microdemic
passed along the detailed error messages that the API provides, as opposed to just giving the HTTP error code. For example:Created on 2019-01-07 by the reprex package (v0.2.0.9000).
Session info
Happy to create a PR for this if you're interested.
The text was updated successfully, but these errors were encountered: