Closed jonquet closed 7 years ago
@jonquet Je viens de tester: curl -X POST http://services.stageportal.lirmm.fr/annotator/\?text\=pharmacocinétique\&longest_only\=false\&exclude_numbers\=false\&whole_word_only\=true\&exclude_synonyms\=false\&expand_mappings\=false\&apikey\=[APIKEY]
La requête est bien POST et ça marche avec les paramètres dans l'URL. J'imagine que tu parle de passer les paramètres en data dans la requête? Comme ceci: curl -X POST http://services.stageportal.lirmm.fr/annotator/ -d 'text=pharmacocinétique&longest_only=false&exclude_numbers=false&whole_word_only=true&exclude_synonyms=false&expand_mappings=false&apikey=c0549e2b-f41f-4764-8779-20a3c949ebba'
Cela ne retourne aucune annotation.
This is not a problem with POST. The proxy receives the parameters correctly in POST as well but always queries the ncbo_annotator with GET. However the problem is that when the parameters are received with POST, the encoding of the text is incorrect and no annotations are returned. When I test with cancer: curl -X POST http://localhost:8082/annotator -d 'text=cancer&longest_only=false&exclude_numbers=false&whole_word_only=true&exclude_synonyms=false&expand_mappings=false&apikey=22522d5c-c4fe-45fc-afc6-d43e2e613169'
I do get the proper annotations.
If I now pass the encoding properly in the header, the proxy gets the accents properly and I get annotations:
curl -H 'Content-Type: application/x-www-form-urlencoded ; charset=UTF-8' -X POST http://localhost:8082/annotator -d 'text=pharmacocinétique&longest_only=false&exclude_numbers=false&whole_word_only=true&exclude_synonyms=false&expand_mappings=false&apikey=22522d5c-c4fe-45fc-afc6-d43e2e613169'
@jonquet Could you post the examples you used to identify the problem?
When the encoding is not specified, Java assumes it's UTF-8 when reading the parameters, when it's intact ISO latin1. So the accent is not recognised properly and ncbo_annotator returns no annotations. ncbo_annotator assumes ISO when no encoding is specified and thus it works when querying data directly but not through the proxy as they work with different encodings
I use DHC on chrome to send my REST queries.
The same call on data.XXX works. Which makes me think this come from the proxy. But it seems there was a mix of 2 things:
The idea would be have our services.XX API as close as the data.XX one... to avoid to document anything "specific to our API" .. could we see on the Java proxy side how to handle this ?
@jonquet The API key problem will be easy to solve, as it only involves copying the headers between the servlet request and the subsequent NCBO annotator request.
For the other problem with the encoding, the fix will require to overhaul the part of the proxy that forwards the request to NCBO annotator to use POST or GET depending on what the annotator proxy received. Currently the proxy always sends a GET, which seems to cause the problem during the encoding conversion between the received POST parameters and their forwarding over the get (during the URL encode stage).
I am currently working on this. The fix for the second problem will also solve #20.
Juste pour info, en faisaint des test pour https://github.com/sifrproject/ncbo_annotator/issues/4 j'ai essayé un appel POST avec "mélanome" qui passe pas. Tandis que l'activation de lemmatize=true fait passer ;)
Fixed in commit 4df4e4a on branch issues_14_16. We will merge branch issues_14_16 with master today.
Il semblerait que les annotator deployés sur services.SOMETHING n'accepte pas les appels en POST, seulement en GET.
Pourtant le service sur data.SOMETHING l'accepte. Je teste sur stage, n’hésitez pas a pousser dessus.