Had already tried that one (as well as pretending to be a browser).
Doing my best to figure out what the difference is.. but no luck so  
far.  Here is the method I'm using (authentication not included but  
working fine).

-ben

public String postToConnotea(String url){
                String response = "";
                BufferedReader in = null;
                try {
                        URL connoU = new URL(url);

                        HttpURLConnection conno = (HttpURLConnection) 
connoU.openConnection 
();
                        conno.setRequestProperty("User-Agent", "WWW::Connotea");
                        conno.setRequestMethod("POST");
                        conno.setDoOutput(true);
                        int code = conno.getResponseCode();
                        System.out.println("code "+code+" for request url 
"+url);
                        switch(code){
                        case 400:
                                conno.disconnect();
                                System.err.println("400 - Server did not like 
form of the request");
                                return null;
                        case 401:
                                conno.disconnect();
                                System.err.println("401 - Server did not accept 
user credentials");
                                return null;
                        case 404:
                                conno.disconnect();
                                System.err.println("404 - Query returned no 
results");
                                return null;
                        case 503:
                                conno.disconnect();
                                System.err.println("503 - Connotea server 
failed to respond");
                                return null;
                        default: //200 all good
                                System.out.println("server accepted request, 
retrieving data");
                                in = new BufferedReader(
                                                new InputStreamReader(
                                                                
conno.getInputStream()));
                                if(in!=null){
                                        response = in.readLine();
                                        in.close();
                                }
                                conno.disconnect();
                        }

                }catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (Exception e) { //catch other exceptions here (like  
SaxParsing exceptions reading RDF)
                        e.printStackTrace();
                }
                return response;
        }




On Aug 2, 2007, at 2:28 PM, Martin Flack wrote:

> Try adding WWW::Connotea in the User-Agent string.
>
> Other than that just try to see what the Java program is doing  
> differently...?
>
> Martin
>
> Benjamin Good wrote:
>> Hi Martin,
>> Switching to POST changes the error to a 400 .
>> I have it working from a simple html form posting through  
>> firefox,  but am trying to get it going in java.  The java program  
>> succeeds in  GETting data from connotea - just can't post.
>> Is there a particular user-agent or other request property that i   
>> should be using?
>> thanks
>> -Ben
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Connotea-code-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/connotea-code-devel

Reply via email to