Reputation: 119
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"}]
}}
Upvotes: 0
Views: 821
Reputation: 6242
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
Upvotes: 1