Note that there are some explanatory texts on larger screens.

plurals
  1. POhttpclient interacting with ncbo annotator, parameters not being set correctly
    primarykey
    data
    text
    <p>I am trying to interact with the NCBO annotator by setting a few parameters, then executing the request. However, the query returns an error: "Forbidden: A valid API key is required to call REST services. Please visit <a href="http://bioportal.bioontology.org/account" rel="nofollow">http://bioportal.bioontology.org/account</a> to get your API key."</p> <p>My scala code is as follows:</p> <pre><code>val annotatorUrl = "http://rest.bioontology.org/obs/annotator" val client = new DefaultHttpClient() var method = new HttpPost(annotatorUrl) val params = new BasicHttpParams params.setParameter("longestOnly", "true") params.setParameter("wholeWordOnly", "true") params.setParameter("filterNumber", "true") params.setParameter("stopWords", "") params.setParameter("withDefaultStopWords", "true") params.setParameter("isTopWordsCaseSensitive", "false") params.setParameter("mintermSize", "3") params.setParameter("scored", "true") params.setParameter("withSynonyms", "true") params.setParameter("ontologiesToExpand", "") params.setParameter("ontologiesToKeepInResult", "") params.setParameter("isVirtualOntologyId", "true") params.setParameter("semanticTypes", "") params.setParameter("levelMax", "0") params.setParameter("mappingTypes", "null") params.setParameter("textToAnnotate", query) params.setParameter("format", "xml") params.setParameter("apikey", "MY_API_KEY") method.setParams(params) val response = client.execute(method) return response.toString() </code></pre> <p>That returns "HTTP/1.1 403 Forbidden [Date: Mon, 02 Apr 2012 21:41:13 GMT, Server: Apache/2.2.13 (Red Hat), Content-Length: 401, Vary: Accept-Encoding, Connection: close, Content-Type: text/xml;charset=UTF-8]"</p> <p>If I run the line:</p> <pre><code>return method.getParams().getParameter("apikey").toString() </code></pre> <p>it returns my correct api key, so it seems that that is being set correctly.</p> <p>Any ideas as to what I am doing incorrectly? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload