0

I am trying to shift my Bing API from old one to new Windows Azure Marketplace

My code is like this:

String serviceUrl = "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/
                    v1/Web?Query='"+ query+"'";

byte[] accountKeyBytes = Base64.encodeBase64(( bingAzureApiKey + ":" + 
       bingAzureApiKey).getBytes());
String accountKeyEnc = new String(accountKeyBytes);

URL celebSearchurl = new URL(serviceUrl);
URLConnection urlc = celebSearchurl.openConnection();
urlc.addRequestProperty("Authorization", "Basic "+accountKeyEnc);
urlc.setConnectTimeout(2500);
urlc.setReadTimeout(2500);

But I am getting 400 error for the same. I am failing to understand what am I doing wrong here?

Yan Berk
  • 14,328
  • 9
  • 55
  • 52
user1374179
  • 47
  • 1
  • 6
  • read here: http://stackoverflow.com/questions/11136936/bing-search-api-azure-marketplace-authentication-in-java – Yan Berk Jul 26 '12 at 09:19

1 Answers1

0

I've started a project at Google Code to make using the new Azure implementation a bit easier. Take a look and see if it helps.

http://code.google.com/p/azure-bing-search-java/

<%
AzureSearchNewsQuery aq = new AzureSearchNewsQuery();
aq.setAppid(AZURE_APPID);
aq.setQuery("Oklahoma Sooners");

aq.doQuery();
AzureSearchResultSet<AzureSearchNewsResult> ars = aq.getQueryResult();
for (AzureSearchNewsResult anr : ars){
        %>
        <h2><%=anr.getTitle()%> (<%=anr.getSource() %>)</h2>
        <p><%=anr.getDate() %></p>
        <p><%=anr.getDescription() %></p>
        <a href="<%=anr.getUrl() %>"><%=anr.getUrl() %></a>
<%}%>