Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending a request to the server using POST

 
Isaac Ferguson
Ranch Hand
Posts: 835
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to send a request to the Google server, using this code:



I have read 300 times the query and I think all is correct

I get the error:




Any idea please?

Many Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are encoding the parameters in the URL - that is for GET operations. Why do you think you need the POST method?

Bill
(400 = request syntactically incorrect)
 
Isaac Ferguson
Ranch Hand
Posts: 835
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,

I am using a POST method because GA launches the "405 invalid method error" if you don´t use it.

Then what way must I encode the URL as String?

Many Thanks,
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:Hi Bill,

I am using a POST method because GA launches the "405 invalid method error" if you don´t use it.

Then what way must I encode the URL as String?

Many Thanks,


For POST the parameters are sent as the body of the request and not as part of the URL.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plus, its better to use a well documented and well tested library, such as the Apache HTTP client software than to write your own. You will get the mainline code to work, but there are lots of edge cases that someone else has solved before you even start.
 
Isaac Ferguson
Ranch Hand
Posts: 835
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works now.

Many Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic