0

I have tried multiple solutions here but none seem to work. I am getting error at String imageJsonStr = sh2.makeServiceCall(imgUrl[i], ServiceHandler.GET); There are no special characters in string and variable imageId is a string containing only numbers like '98546214265231'

                             imgUrl[i] = "https://graph.facebook.com/v2.2/"
                                        + imageId
                                        + "?access_token="
                                        + static_token;                                                 
                                try {

                                    try {
                                        imgUrl[i] = URLEncoder.encode(imgUrl[i],"UTF-8");
                                    } catch (UnsupportedEncodingException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                    String imageJsonStr = sh2.makeServiceCall(
                                            imgUrl[i], ServiceHandler.GET);
5
  • log the value of imgUrl[i] after encoding it using URIEncoder .. Commented Mar 25, 2015 at 5:24
  • https%3A%2F%2Fgraph.facebook.com%2Fv2.2%2F%5BLjava.lang.String%3B%4042477c08%3Faccess_token%3DCAAK43Qt9dQUBAF0ZC3LYE828xyaaQgTccYYpWBmO7sqcsll4S3lhnVdBH0JrV30qPjjLWPwy0lPR0ZAt8Tsl5se0OGWWQejybyEWZCmPXJdjBhorBNWAudWXEZAuVaQnrpMkmcZAGsGO31aIHZA8SttfEkEi4rntmIweZBluWJ2ZAHi40tqiiXZCp*********************************************** Commented Mar 25, 2015 at 5:34
  • so u have to encode only your url parameters..the whole uri could not be encoded.. Commented Mar 25, 2015 at 5:36
  • I can also do it manually right? like this ?"access_token%33DCAAK43Qt9dQUBAF0ZC3LYE***..." Commented Mar 25, 2015 at 5:38
  • i think that will work.. Commented Mar 25, 2015 at 5:40

1 Answer 1

1

Java URL encoding of query string parameters refer this.. you need not encode the entire url .. encode only the parmaters

Sign up to request clarification or add additional context in comments.

5 Comments

do i need to encode Url even if there are no special characters after '?' ?
if there is no special characters then no need to encode..special chars includes spaces also..parameter encoding will be safe..
I removed URLEncoder. I am getting "Illegal character in path at " starting of imageId .My imageId is a string containg all numbers
if your accesstoken doesn't have any spaces try this. don't do any encoding stuffs
yes removing URLEncoder solved that problem. can you please tell me why am I getting "Illegal character in path" ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.