I'm trying to upload an image as profile picture using WhatsApp Cloud API *.

After creating an application using WhatsApp Cloud API I'm not allowed to access neither using the regular application nor using Business Application. It says something like "try again in one hour". So I have to implement everything using the API.

After reading the docs and importing Postman Endpoints I found the one called Business Profiles > Update Business Profile

https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile

It has a field "profile_picture_url"and I have tried POSTing media https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/media and then with the given ID y used https://graph.facebook.com/{{Version}}/{{Media-ID}} to get the URL but it didn't work. The rest of the information is updated successfully

{     "messaging_product": "whatsapp",     "address": "",     "description": "Simple Bot",     "email": "...@gmail.com",     "websites": [         "https://..."     ],     "profile_picture_url": "https://lookaside.fbsbx.com/..." } 

However if I try to send someone using the ID and the endpoint https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/messages it works fine. And if I use Download Media Content with the URL in Postman it works fine too.

I don't know if I have misunderstood something or if it can't be done using the API.

Tag:cloud, postman, whatsapp

5 comments.

  1. Dendy

    It is mentioned in the Cloud API Documentation:

    profile_picture_url (Optional): URL of the profile picture generated from a call to the Resumable Upload API.

    But, i got it working using profile_picture_handle instead of profile_picture_url. So how do we get the profile_picture_handle?

    Prerequisite:

    Graph API token here. Or use your WhatsApp Cloud API token. App ID, go Apps > Your App > Settings (sidebar menu) > Basic

    Update Photo Profile:

    Call POST https://graph.facebook.com/v14.0/{{appId}}/uploads?access_token={{token}}&file_length={{fileSizeInByte}}&file_type=image/jpeg Save the session id you got, upload:XXXXXX?sig=XXXXXX. Call POST https://graph.facebook.com/v14.0/{{sessionId}}, with the headers: Authorization=OAuth {{token}}, file_offset=0, Host=graph.facebook.com, Connection=close, Content-Type=multipart/form-data, and include your image file in the request body with type binary. If you using Postman, see image below (This is what I missed for hours). Save the handle result you got, 4::XXX==:XXXXXX. Finally, call POST https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile, with json request body: {"messaging_product": "whatsapp", "profile_picture_handle": "4::XXX==:XXXXXX"}

    That's it, You can check the profile picture.

    1. Youzef

      I can't get step 5 to go through.

    2. Youzef

      Uuurghh!! Meta APIs are overly complicated for no reason. Why call three different endpoints just to upload a picture? On top of this there is a token and three other user specific variables, and a Facebook developer account with password and 2FA??

    3. Dave Chong

      It works. I got the profile picture updated. Thank you.~

  2. cigien

    The last step you have to add your taken by selecting "Bearer" or else it will give you error. I had hard time on the last ones, do all the steps and then go to the following link and it should help.

    https://web.postman.co/workspace/My-Workspace~a4ddb3b8-02a3-4132-8384-66e63e149b7b/request/22958165-506a0542-c845-41ac-b3fb-b8209fd6f53b

Add a new comment.