httr::POST / query_results$status_code=502

Hello,
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")

library(httr)

# The MetaboAnalyst API url
call <- "https://www.xialab.ca/api/mapcompounds"

# 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.
query_results$status_code==200

# 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(rbind.data.frame(query_results_json))
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 ‘https://rest.xialab.ca/api/mapcompounds’. 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.

Hi @jeff.xia,
Can you estimate when the API will be up again? I developed a tool that relies on the mapcompounds API in the background, and using the web platform is not suitable for me. Do you know of any alternatives in the meantime? I could not find any API that allows for inexact compound matching. Thank you for your help!

Hello @jeff.xia,

I think the web version for mapping compound is also down. I tried it with both my data and the example and none seemed to work.

Also, same situation with @Daniel_Dehncke, can you estimate when the API will be up again?

Thank you so much for your response!