Effacer les filtres
Effacer les filtres

EMBL RESTful API post request error

8 vues (au cours des 30 derniers jours)
Sandrine
Sandrine le 27 Déc 2020
Commenté : Sandrine le 27 Déc 2020
Hello,
I would like to post a request to the EMBL RESTful API (well known Bioinformatics database) to get data relative to two different IDs (as an example: ENSG00000157764 and ENSG00000248378) but I am encountering the following error:
server = 'https://rest.ensembl.org';
ext = '/lookup/id';
data = '{ "ids" : ["ENSG00000157764", "ENSG00000248378" ] }';
options = weboptions('ArrayFormat','json','MediaType','application/json','HeaderFields',{'Content-Type' 'application/json';'Accept' 'application/json'},'RequestMethod','post');
r = webwrite([server,ext],data, options);
Error using webwrite (line 136)
Internal error: "curl_multi_remove_handle" failed with CURLMcode API function called from
within callback.
I am able to run this request using Python 3 like in there:
As part of the BioInformatics toolbox there are functions (getembl, emblread) but I cannot get them to work either.
Maybe it is a syntax problem or an option that I did not specify. I'll be happy to submit the MATLAB version for their website.
Thank you very much for the help!
Sandrine

Réponse acceptée

Ive J
Ive J le 27 Déc 2020
You are almost there, except that MATLAB doesn't have a dictionary data type as Python3 has, so you should construct a struct instead:
getURL = 'https://rest.ensembl.org/lookup/id';
headers = {'Content-Type' 'application/json'; 'Accept' 'application/json'};
options = weboptions('RequestMethod', 'post', 'HeaderFields', headers, 'ArrayFormat', 'json');
data = struct('ids', ["ENSG00000157764", "ENSG00000248378"]);
r = webwrite(getURL, data, options)
struct with fields:
ENSG00000248378: [1×1 struct]
ENSG00000157764: [1×1 struct]
  1 commentaire
Sandrine
Sandrine le 27 Déc 2020
Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by