Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook Graph API request error when using HTTP POST / DELETE method
    primarykey
    data
    text
    <p>I'm developing an Android app which is integrated with Facebook SDK.</p> <p>First I'm fetching the feeds of a Facebook page using Graph API, which is working fine. I want to allow the users to like &amp; post comments against each feed.</p> <p>I'm using the following code snippet for <strong>Like</strong></p> <pre><code>Bundle parameters = new Bundle(); parameters.putString("access_token", access_token); String response = null; String id = &lt;Target Feed ID&gt;; try { response = facebook.request(id+"/likes", parameters, "POST"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.i("FB Like Output", ""+response); </code></pre> <p>But I'm getting NullPointerException at the following line:</p> <pre><code>response = facebook.request(id+"/likes", parameters, "POST"); </code></pre> <p>Please note that this error occurs <strong>only when I'm using "POST" or "DELETE" as the 3rd parameter</strong>. Instead if i'm using GET I get a proper response (which however, won't serve my purpose). </p> <p>Also, I've added relevant permissions like <strong>publish_stream</strong>.</p> <p>Is this the correct syntax for making a Synchronous request using HTTP POST method ?</p> <pre><code>04-25 16:29:08.332: E/AndroidRuntime(710): FATAL EXCEPTION: main 04-25 16:29:08.332: E/AndroidRuntime(710): java.lang.NullPointerException 04-25 16:29:08.332: E/AndroidRuntime(710): at java.net.URLDecoder.decode(URLDecoder.java:130) 04-25 16:29:08.332: E/AndroidRuntime(710): at java.net.URLDecoder.decode(URLDecoder.java:68) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.facebook.android.Util.openUrl(Util.java:186) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.facebook.android.Facebook.requestImpl(Facebook.java:806) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.facebook.android.Facebook.request(Facebook.java:794) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.test.myapp.adapters.FacebookAdapter$1.onClick(FacebookAdapter.java:107) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.view.View.performClick(View.java:2408) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.view.View$PerformClick.run(View.java:8816) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.os.Handler.handleCallback(Handler.java:587) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.os.Handler.dispatchMessage(Handler.java:92) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.os.Looper.loop(Looper.java:123) 04-25 16:29:08.332: E/AndroidRuntime(710): at android.app.ActivityThread.main(ActivityThread.java:4627) 04-25 16:29:08.332: E/AndroidRuntime(710): at java.lang.reflect.Method.invokeNative(Native Method) 04-25 16:29:08.332: E/AndroidRuntime(710): at java.lang.reflect.Method.invoke(Method.java:521) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 04-25 16:29:08.332: E/AndroidRuntime(710): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-25 16:29:08.332: E/AndroidRuntime(710): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload