httr::POST / query_results$status_code=502

My R code worked fine until recently. I’m trying to retrieve KEGG metabolic pathways from metabolite names. However, recently I noticed that the API wasn’t working and consequently my code wasn’t working either. I’ve tried several types of script, updated packages … But it seems that the error is coming from the server, because using the code in the “MetaboAnalyst” tutorial

name.vec <- c("1,3-Diaminopropane;2-Ketobutyric acid;2-Hydroxybutyric acid;2-Methoxyestrone")
toSend = list(queryList = name.vec, inputType = "name")


# The MetaboAnalyst API url
call <- ""

# Use httr::POST to send the request to the MetaboAnalyst API
# The response will be saved in query_results
query_results <- httr::POST(call, body = toSend, encode = "json")

# Check if response is ok (TRUE)
# 200 is ok! 401 means an error has occured on the user's end.

# Parse the response into a table
# Will show mapping to "hmdb_id", "kegg_id", "pubchem_id", "chebi_id", "metlin_id", "smiles" 
query_results_text <- content(query_results, "text", encoding = "UTF-8")
query_results_json <- rjson::fromJSON(query_results_text, flatten = TRUE)
query_results_table <- t(
rownames(query_results_table) <- query_results_table[,1]

I get code 502 (query_results$status_code==200 egal FALSE) and then it’s impossible to get the results of the query "query_results_json ← rjson::fromJSON(query_results_text)
Error in rjson::fromJSON(query_results_text) :
not all data was parsed (0 chars were parsed out of a total of 3376 chars).

Thank you for your help, I am a novice in bioinformatics and maybe this is due to a misunderstanding on my part. I can’t wait to find the solution to my problem :wink: !!!

Please note that the API endpoint appears to have been updated to ‘’. However, there also seems to be an issue with this URL. I’m unable to run the example provided on MetaboAnalyst

Thanks for your help. I hope it will be resolved soon.

I am having the same problem but my error is 500. The code used to work well before the change of API URL though.

Thank you all. Our API server is under maintenance due to recent hard drive failure. Our priority is web platform giving the limited resources. We hope to restore API soon.