0

First of all I'm sorry for my English. I am developing an application in java and I want to use search Bing API, So I opened user-centered development of Bing (http://www.bing.com/dev/en-us/dev-center) and accept key number then I wrote the following code to get results Bing

String q = "http://api.bing.net/json.aspx?Appid=MyClientId=girls&sources=web&web.count=40&web.offset=41";

URL searchURL;
try {
    searchURL = new URL(q);
    HttpURLConnection httpURLConnection = (HttpURLConnection) searchURL.openConnection();

    if(httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK){
        InputStreamReader inputStreamReader = new InputStreamReader(httpURLConnection.getInputStream());
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader, 8192);

        String line = null;
        String result = "";
        while((line = bufferedReader.readLine()) != null){
            result += line;
        }

        bufferedReader.close();
    }
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Why do I get the following error 1002?

{"SearchResponse":{
    "Version":"2.2",
    "Query":{"SearchTerms":"girls"},
    "Errors":[
        {"Code":1002,
         "Message":"Parameter has invalid value.",
         "Parameter":"SearchRequest.AppId",
         "Value":"MyClientId",
         "HelpUrl":"http:\/\/msdn.microsoft.com\/en-us\/library\/dd251042.aspx"}]
}}
quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
user2320349
  • 109
  • 1
  • 12

1 Answers1

1

It looks like you've got a typo in the address This looks very suspicious:

Appid=MyClientId=girls

You should see the documentation http://msdn.microsoft.com/en-us/library/dd250882.aspx, but I guess that you need to replace the MyClientId with something and also you haven't spearated the query and the clientId i.e. &q=girls

EDIT: You need to get the AppId somewhere Steps of creating appid for bing search

Here's some question which can help you: Bing search API and Azure

Community
  • 1
  • 1
NeplatnyUdaj
  • 6,052
  • 6
  • 43
  • 76
  • First of all thanks for the quick response I fixed the problem of Appid = MyClientId = girls but it's still not working I read the documentation but I could not figure out where I put the key in url address by documentation Thanks again for the help – user2320349 Jan 20 '14 at 10:04