Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Internal server error for programmatic search

Maxwell Neal mneal at u.washington.edu
Fri Dec 20 16:10:39 PST 2013


Ray & Paul,

I believe I figured out the issue. I needed to add this line to my code:

yc.setRequestProperty("Accept", "application/xml");

(yc is a URLConnection instance.)

Once I added it, I was able to retrieve a successful response.

Thanks once again for your help!

(If that example code you sent is not available on the API documentation page, I would recommend adding it!)

Best,

M

---------------------------------
Maxwell Neal

Post-doctoral researcher
Department of Bioengineering
University of Washington
mneal at uw.edu
---------------------------------








On Dec 20, 2013, at 6:23 PM, Ray Fergerson wrote:

> This is really quite strange since it works in a browser. It works for us as well. Do you get other connections to work?
>  
> I suggest perhaps cutting the command down to the minimum to see if the connection can be established. Something like:
>  
> http://data.bioontology.org/search?q=brainstem&apikey=...
>  
> If this works then try building up the command you want.
>  
> If even this does not work then perhaps there is some bizarre firewall setting that only allows known browsers at your site to access the web. I have no idea if this sort of thing is really even possible. I would be worthwhile though trying the same command from your home internet connection without going through the UW network.
>  
> Ray
>  
> From: bioontology-support-bounces at lists.stanford.edu [mailto:bioontology-support-bounces at lists.stanford.edu] On Behalf Of Maxwell Neal
> Sent: Friday, December 20, 2013 2:05 PM
> To: Paul R Alexander
> Cc: support at bioontology.org
> Subject: Re: [bioontology-support] Internal server error for programmatic search
>  
> Hi Paul,
>  
> Thanks very much for the help.  When I use the API key parameter in my Java code I still get the same HTTP 500 error. Here's an example:
>  
> http://data.bioontology.org/search?q=brainstem&ontologies=FMA&format=xml&exact_match=0&apikey=c4192e4b-88a8-4002-ad08-b4636c88df1a
>  
> Again, this call works fine in a browser, but not from my Java code.
> 
> Cheers,
>  
> M
>  
> ---------------------------------
> Maxwell Neal
>  
> Post-doctoral researcher
> Department of Bioengineering
> University of Washington
> mneal at uw.edu
> ---------------------------------
>  
>  
>  
>  
>  
>  
> 
>  
> On Dec 20, 2013, at 2:36 PM, Paul R Alexander wrote:
> 
> 
> You will need to pass along your API Key using the ‘apikey=YOUR_APIKEY’ parameter when you do the request from code. It gets stored in a browser cookie and so you may be able to access from your browser just fine.
> 
> Here is some sample java code for doing search (The API key here gets set in a header, but passing the apikey query string parameter works as well):
> https://github.com/ncbo/ncbo_rest_sample_code/blob/master/java/src/ClassesSearch.java
> 
> Paul
> 
> 
> On Dec 19, 2013, at 12:16 PM, Maxwell Neal <mneal at u.washington.edu> wrote:
> 
> 
> Hi all,
>  
> I am in the process of adapting some existing Java code that I use to programmatically search ontologies in BioPortal.  When I try to open a connection to the following BioPortal REST URL, I get an HTTP 500 error.
>  
> http://data.bioontology.org/search?q=brainstem&ontologies=FMA&format=xml&exact_match=0
>  
> When I paste the same URL into my browser, I do get a successful search result.
>  
> Is this really an error on the BioPortal side, as the HTTP code indicates? (I've included a snippet of my code below, in case it's useful.)
>  
> Many thanks,
>  
> M
>  
>  
> String text = "brainstem";
> String bioportalID = "FMA";
> SAXBuilder builder = new SAXBuilder();
> Document doc = null;
> text = text.replace(" ", "+");
> URL url = new URL(
>             "http://data.bioontology.org/search?q="
>                         + text + "&ontologies="
>                         + bioportalID + "&format=xml" + "&exact_match=" + exactmatch);                                              
>                                    
> System.out.println(url);
> URLConnection yc = url.openConnection();
> yc.setReadTimeout(60000); // Timeout after a minute
> BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
>  
>  
>  
>  
> ---------------------------------
> Maxwell Neal
>  
> Post-doctoral researcher
> Department of Bioengineering
> University of Washington
> mneal at uw.edu
> ---------------------------------
>  
>  
>  
>  
>  
>  
>  
>  
> _______________________________________________
> bioontology-support mailing list
> bioontology-support at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/bioontology-support
>  
>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20131220/c5d657b7/attachment-0001.html>


More information about the bioontology-support mailing list