0

I had to do HTTP POST, authenticated with the key. I had the key with me and also url.

But am getting 400 response code i.e, bad request error.

My code is:

Authenticator.setDefault(new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                       return new PasswordAuthentication("sixxxxxxxx","xxxxxxxxxTGh7fYbA:xxxxxxoRtGnOIb_vno1wQ".toCharArray());
                       }
                });

I found this is for username and password. But i want to authenticate with specific key only

How to do this?

Thanks

Udaykiran
  • 5,705
  • 9
  • 41
  • 75
  • Do you mean key like private key? I was looking into HTTP RFC and I think something like HTTP POST cannot be authenticated with such key. Maybe in SSL or I don't get the question well. – Mateusz Oct 11 '11 at 11:46
  • key means like a secret key ( Credentials are supplied via HTTP Basic Auth, always over our HTTPS connection. ) this was said . – Udaykiran Oct 11 '11 at 11:50
  • and my url is: https://go.urbanairship.com/api/airmail/send/broadcast/ – Udaykiran Oct 11 '11 at 11:54
  • Ok, so you can just create HTTP Methods HttpURLConnection and setRequestMethod(String) there you can specify POST fields in header – Mateusz Oct 11 '11 at 12:05
  • example: http://developers.sun.com/mobility/midp/ttips/HTTPPost/ it should be the same for android – Mateusz Oct 11 '11 at 12:06

0 Answers0