3
votes

i followed the youtube data api to rate the video from the app. But i got "not found 404 error."

https://www.googleapis.com/youtube/v3/videos/rate?id=Z98hXV9GmzY&rating=like&access_token="+token+"&key=XXXXX

what is the right way to do that... Any help is appreciated. Thankyou

I'm using codename one platform for the app by the way..

Login gc = GoogleConnect.getInstance();
gc.setCallback(new LoginCallback() {
                @Override
                public void loginFailed(String errorMessage) {
                    Dialog.show("Error Logging In", "There was an error logging in: " + errorMessage, "OK", null);
                }

                @Override
                public void loginSuccessful() {
                    Dialog.show("Logged In", "you are currently logged in ", "OK", null);

                }
            });
            if (!gc.isUserLoggedIn()) {
                gc.doLogin();
            } else {
                token = gc.getAccessToken().getToken();
            }
        });


        findLikes(f).addActionListener((e) -> {

            ConnectionRequest cr = new ConnectionRequest() {

                @Override
                protected void readResponse(InputStream input) throws IOException {
                    super.readResponse(input);
                }

                @Override
                protected void postResponse() {
                    super.postResponse();
                }

            };
            cr.setPost(false);
            cr.setUrl("https://www.googleapis.com/youtube/v3/videos/rate?id=" + videoId + "&rating=like&access_token="+token+"&key=XXXXX");  //this doesnt give anything... is it not the right way??
            cr.setDuplicateSupported(true);
            NetworkManager.getInstance().addToQueueAndWait(cr);
        });
2

2 Answers

0
votes

you can not directly rate from the url. you need to use full rating code to give rate. Youtube API

because firstly google authenticate of your application then it allows you to give rate Not directly from the Your link

0
votes

First off please tell use what language you are using I cant figure it out exactly from your code.

Videos: rate Add a like or dislike rating to a video or remove a rating from a video.

POST https://www.googleapis.com/youtube/v3/videos/rate

Remember this call is a http post not a HTTP GET. Ie you cant just place it in a web browser.

example:

POST https://www.googleapis.com/youtube/v3/videos/rate?id=b_bJQgZdjzo&rating=like&oauth_token={YOUR_accessTOken}

I am pretty sure it is oauth_token you use not key or access_token.