Reputation: 1
the following code :
HttpClient client = new DefaultHttpClient();
try{
HttpGet request = new HttpGet(x);
request.setHeader("Authorization", "Basic:accound id");
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(request, responseHandler);
System.out.println(responseBody);
}
where x = ="https://api.datamarket.azure.com/Bing/SearchWeb/vl/Web?Query=%27query%20";
gives following error : org.apache.http.client.HttpResponseException: The authorization type you provided is not supported. Only Basic and OAuth are supported what could be solution fo it?
Upvotes: 0
Views: 994
Reputation: 1
the code should be something like
String accountKey = "xxxxxxxxxxx";
byte[] accountKeyBytes = Base64.encodeBase64((accountKey + ":" + accountKey).getBytes()); String accountKeyEnc = new String(accountKeyBytes);
request.setHeader("Authorization",
"Basic" + " "+accountKeyEnc);
Upvotes: 0
Reputation: 11454
The authorization header needs to be Base64 encoded; username is left empty, password is account id.
Upvotes: 1