• Post Reply Bookmark Topic Watch Topic
  • New Topic

IOException: Server returned HTTP response code: 405  RSS feed

 
bernard kissi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to use an API for sending message in my java project and receiving a son response after the message has been sent.
i download the code sample from the website of the company
but when i try executing the codes i receive an error : Server returned HTTP response code: 405 for URL: http://sms.nasaramobile.com/api?

Below is the api sample code to be used for this implementation provided by the company


How can fix this error ........of  Server returned HTTP response code: 405 for URL: http://sms.nasaramobile.com/api?

What i need to do is first send a post request to the server passing sender, receiver and the message parameter to the API url
i tried in my browser when i add the supported paraments to  the api and run it through my browser the message gets sent but in java program it returns 405 error
how can i fix this ?

first POST request to send message and A GET request to receive response
 
Dave Tolls
Ranch Hand
Posts: 2846
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why have you got a '?' at the end of your URLs?

Especially since your parameters are in the POST body.
 
bernard kissi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://sms.nasaramobile.com/api?api_key=5950b4XXXXe315XXXX4f3bXXXX&sender_id=hello&phone=054534XXXX&message=+hello in the browser 
 
bernard kissi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which gives a 1801 which means message sent
 
Dave Tolls
Ranch Hand
Posts: 2846
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that's a GET, not a POST.

Currently you are (if I've read your code correctly) sending a POST to
http://sms.nasaramobile.com/api?
with some JSON in the body containgin something like:
api_key=5950b4XXXXe315XXXX4f3bXXXX&sender_id=hello&phone=054534XXXX&message=+hello

 
bernard kissi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in that case how do i rewrite the codes to send a POST rather than GET
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!