View Single Post
Old 08-24-2012, 10:21 AM   #2 (permalink)
LCBStanley
New Member
 
Join Date: Aug 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Pushing to BES from application

connection.setDoOutput(true);

connection.setRequestMethod("POST");
connection.setFollowRedirects(true);

String query = "summary=" + "test";
query += "&";
query += "body=" + "testtesttest body";

connection.setRequestProperty("Content-length",String.valueOf (query.length()));
connection.setRequestProperty("Content-Type","text/plain");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (BlackBerry; U; BlackBerry AAAA; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/X.X.X.X Mobile Safari/534.11+");

// open up the output stream of the connection
DataOutputStream output = new DataOutputStream( connection.getOutputStream() );

// write out the data
int queryLength = query.length();
output.writeBytes( query );
output.close();

System.out.println("Resp Code:"+connection.getResponseCode());
System.out.println("Resp Message:"+ connection.getResponseMessage());
}
catch(Exception e)
{
System.out.println( "Something bad just happened." );
System.out.println( e );
e.printStackTrace();
}
}
}
Offline   Reply With Quote