-1

I create test WebServices and i am trying to get json form this url

https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20flickr.groups.info%20WHERE%20group_id%3D'22637658%40N00'&format=json&diagnostics=true&callback=

all the time i get ERROR 400,also yahoo gave to me a secret id and key but i don׳t know where to set them. when i cheak the method with:test http request everything work fine.

WEB SERVICES CODE:

 public static void httpRequest(String params, String urlAdress, final CallbackBool callback){
        try {

            URL url = new URL("https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20flickr.groups.info%20WHERE%20group_id%3D'22637658%40N00'&format=json&diagnostics=true&callback=");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setReadTimeout(10000);
            connection.setConnectTimeout(15000);
            connection.setDoOutput(true);
            Log.i("SHOW CONNECTION:",connection.toString());
            getJsonData(connection, new ResponseCallback<String>() {
            @Override
            public void onSuccess(String result) {
                Log.i("SHOW NEW JSON",result);
                callback.doJob(true);
            }

            @Override
            public void onFailure(String result) {
                Log.i("FAILLL!","FAILLL");
                callback.doJob(false);
               }
           });
          } catch (MalformedURLException e) {
              e.printStackTrace();
              callback.doJob(false);
          } catch (IOException e) {
              e.printStackTrace();
              callback.doJob(false);
          }
}

my result:ERROR CONNECTION: 400

Where i need to put/set the key and the secret id and how?

Community
  • 1
  • 1
moshe kobi
  • 71
  • 1
  • 7
  • Refer to the Yahoo documentation instead – Zoe Mar 05 '17 at 14:47
  • i did not understand....so i do not need to put the sercret id and the key in the request? :/ – moshe kobi Mar 05 '17 at 14:48
  • How else will Yahoo get it? Consider a door with a normal key(not wireless, not code, just a normal key). You try to open the door, but it is locked(Error 400). You have the key in your pocket but you don't use it. How will the door(Yahoo) open when it requires a key you do not supply? – Zoe Mar 05 '17 at 14:51
  • i have the key but dont know where to set it....this is my question – moshe kobi Mar 05 '17 at 14:52

1 Answers1

0

Anywhere in your URL, add:

&api_key=[your key here]

To add it to the end:

url += "&api_key='" + api_key + "'";

If you open the URL you supplied in the browser, this result shows up:

{"error":{"lang":"en-US","diagnostics":{"publiclyCallable":"true"},"description":"Cannot find required keys in where clause;  got 'group_id', expecting required keys: (api_key,group_id)"}}

It is missing the api_key.

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • `https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20flickr.groups.info%20WHERE%20group_id%3D'22637658%40N00'&format=json&diagnostics=true&callback="+"&api_key="+apiKey` .....i did like this and still does not working – moshe kobi Mar 05 '17 at 15:06
  • remove or supply a callback (&callback=) and make sure the API key is valid. Copy the full link and open in your browser to get teh error message. Make sure the api key is there and it isn't a variable name – Zoe Mar 05 '17 at 15:07
  • i remove the callback it did not work...but i am trying to understand what did you mean by "supply a callback"....sorry for my bad english – moshe kobi Mar 05 '17 at 15:12
  • `Query syntax error(s) [line 1:6 expecting fields_or_star got ' ']`....show me this error – moshe kobi Mar 05 '17 at 15:14
  • "Supply a callback" means give it something as a callback. Not sure what it takes for input though.As to solve the issue, it may require `'` around it. See update – Zoe Mar 05 '17 at 15:55