androidpinterestpdk

Pinterest PDK createPin(...) issue


While creating a new pin using PDK's createPin() method for Android app,

public void createPin(String note, String boardId, String imageUrl, String link, PDKCallback callback)

it throws error response with error code 400, With no proper error message. Below is the code that I have been using.

String note = "Hello World!";
String boardID = "130323051656269527";
String imgURL = "https://www.instagram.com/p/BXB_J-mld0Z/?taken-by=chelseasmakeup";
PDKClient.getInstance().createPin(note, boardID, imgURL,null,
                    new PDKCallback() {
                        @Override
                        public void onSuccess(PDKResponse response) {
                            Log.e("TAG", "response: " + response.toString());
                        }

                        @Override
                        public void onFailure(PDKException exception) {
                            exception.printStackTrace();
                        }
                    });

There is nothing worng with the boardID as other api with same boardID works fine. Just creating new pin fails. I couldn't find the solution for this one.

Here is the Log

PDK POST: https://api.pinterest.com/v1/pins/ 
BasicNetwork.performRequest: Unexpected response code 400 for https://api.pinterest.com/v1/pins/?access_token=AX4CNtTbNh5ftBz7W1gIcr8gpNFQFNW6RGIDvLtEMpH7NmBEFgAAAAA

com.pinterest.android.pdk.PDKException
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at com.pinterest.android.pdk.PDKCallback.onErrorResponse(PDKCallback.java:28)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at com.android.volley.Request.deliverError(Request.java:598)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:101)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at android.os.Looper.loop(Looper.java:154)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6077)
07-29 12:19:35.320 2316-2316/com.simplify360.suit.testapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
07-29 12:19:35.321 2316-2316/com.simplify360.suit.testapp W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-29 12:19:35.321 2316-2316/com.simplify360.suit.testapp W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

Solution

  • Change the line

    if (!Utils.isEmpty(link)) params.put("image_url", imageUrl);

    with

    if (!Utils.isEmpty(imageUrl);)) params.put("image_url", imageUrl);

    Later when you are passing the image URL, make sure the URL has an extension as like "http://goldwallpapers.com/uploads/posts/blue-tiger-wallpaper/blue_tiger_wallpaper_001.jpg." URL like "https://www.instagram.com/p/BUAs-jVF9Fx/?taken-by=chelseasmakeup" didn't work.