Yes..  that did seem strange and is, of course, wrong.  Apologies for  
my idiocy.
However, I can't get it to work with the methods you directed me to  
either.  Always get the 400 response.

any other ideas?
-Ben

String uri = "http://www.cnn.com";;
String tags = "test123";

String encodedData = URLEncoder.encode("uri="+uri 
+"&tags="+tags,"UTF-8");
                
                        URL connoU = new 
URL("http://www.connotea.org/data/add";);                       
                        HttpURLConnection conno = (HttpURLConnection) 
connoU.openConnection 
();
                        
                        conno.setRequestProperty("User-Agent", "WWW::Connotea");
                        conno.setRequestProperty("Content-Type", 
"application/x-www-form- 
urlencoded");
                        conno.setRequestMethod("POST");
                        conno.setRequestProperty( "Content-Length", 
""+encodedData.length 
() );
                        conno.setDoOutput(true);
                        conno.setDoInput(true);
                        conno.setUseCaches(false);
                        OutputStream os = conno.getOutputStream();
                        os.write( encodedData.getBytes() );
                        os.flush();
                        os.close();
                        int code = conno.getResponseCode();
                        System.out.println("response code from connotea="+code);



On Aug 2, 2007, at 5:45 PM, Martin Flack wrote:

> I don't know Java libraries, but it seems unlikely that you should  
> be using setRequestProperty() for both User-Agent (an HTTP header)  
> and uri (a form parameter).
>
> POST's are supposed to put their parameters in the payload (like  
> your web browser does) by spec.
>
> Take a look at how they encode and attach the form payload on these  
> examples:
> http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
> http://developers.sun.com/mobility/midp/ttips/HTTPPost/
>
> Cheers,
> Martin
>
> Benjamin Good wrote:
>> Usually adding the parameters into the URL works .. why would it  
>> not in this case?
>> I get the same error (400) if I set the params in the code
>> URL connoU = new URL("http://www.connotea.org/data/add";);
>> HttpURLConnection conno = (HttpURLConnection) connoU.openConnection 
>> ();
>> conno.setRequestProperty("User-Agent", "WWW::Connotea");
>> conno.setRequestProperty("uri", URLEncoder.encode(uri,"UTF-8"));
>> conno.setRequestProperty("tag", URLEncoder.encode(tag,"UTF-8"));
>> conno.setRequestMethod("POST");
>> I've been digging for some else that has this running in Java, but  
>> the only one I could find (from Pierre Lindenbaum) didn't use the  
>> web api - it emulated a user session by storing and sending  
>> cookies for authentication and sending requests including button  
>> clicks.  (His ConnoteaClient program - but it doesn't seem to be  
>> work ing anymore).
>> -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