Are you looking to write the parameters as application/x-form-
urlencoded into the POST body or simply add them as parameters in the
url?

For the case where you want to write to the post body I have had
success with something like the following:

     //create the url encoded post body as a string
     //
deviceToken=760ff5e341de1ca9209bcfbd320625b047b44f5b394c191899dd5885a1f65bf2&notificationText=What
%3F&badgeNumber=4&sound=default&payload=5+and+7
     String postBody =
"deviceToken=760ff5e341de1ca9209bcfbd320625b047b44f5b394c191899dd5885a1f65bf2&notificationText=What
%3F&badgeNumber=4&sound=default&payload=5+and+7"
     URL url = new URL("http://www.example.com/comment";);
     HttpURLConnection connection =
(HttpURLConnection)url.openConnection();
     connection.setDoOutput(true);
     connection.setRequestMethod("POST");
     connection.getOutputStream().write( postBody.getBytes() );

On Apr 25, 1:58 pm, Icarus <[email protected]> wrote:
> Hi,
>
>  I am trying the Google App Engine for Java link for making a HTTP
> Post request from my Web App.
>
> I am using the following code from the example 
> :http://code.google.com/appengine/docs/java/urlfetch/usingjavanet.html
>
>  URL url = new URL("http://www.example.com/comment";);
>             HttpURLConnection connection = (HttpURLConnection)
> url.openConnection();
>             connection.setDoOutput(true);
>             connection.setRequestMethod("POST");
>
>             OutputStreamWriter writer = new
> OutputStreamWriter(connection.getOutputStream());
>             writer.write("message=" + message);
>             writer.close();
>
> How do I actually set the parameters for a POST call ? I tried the low
> level API but it requires a byte[]. How do we initialize that ?
>
> Thanks,
> Ic

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to