Posts tagged with facebook-graph-api

I'm working on sending WhatsApp messages through the Meta (Facebook) Graph API using the following endpoint:

https://graph.facebook.com/v21.0/${{phoneNumber-id}}/messages 

Here is the body

{   "messaging_product": "whatsapp",   "to": "",   "type": "template",   "template": {     "name": "hello_world",     "language": {       "code": "en_US"     }   } } 

However, when I hit the API, I receive the following error response:

{     "error": {         "message": "Unsupported post request. Object with ID '${{phoneNumber-id}}' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",         "type": "GraphMethodException",         "code": 100,         "error_subcode": 33,         "fbtrace_id": "Ap51V1Qjcw1Vh8LJ4aeP0Fm"     } } 

I am using test number provieded by facebook to send messages, I’ve verified my access token and permissions but still encounter this error.

What could be causing this issue? Are there any specific permissions or configurations I might be missing, or is there something wrong with how I’m referencing ${{phoneNumber-id}} in the endpoint? Any help or insights with the WhatsApp API would be greatly appreciated.

I'm working on a Django API that integrates with the Meta API for WhatsApp product feeds. This endpoint works perfectly on my local machine, but when I deploy it to production, it returns a 504 Gateway Timeout error.

Details:

Local Request (Works):

curl -X POST http://127.0.0.1:8000/api/whatseat/save-changes/ -d "business_id=2"

Production Request (504 Gateway Timeout):

curl -X POST https://<production-url>/api/whatseat/save-changes/ -H "Authorization: Token <token>" -d '{"business_id": 2}'

Key Observations:

  • Error happens only in production—locally, the endpoint works fine.
  • When this endpoint is called without the necessary WhatsApp data, it correctly returns a prompt to complete settings. So, the problem seems to occur during an external API request to the Meta (WhatsApp) API.
 def post(self, request):     business_id = request.data.get('business_id')          try:         whatsapp_business = WhatsApp.objects.get(business=business_id)     except ObjectDoesNotExist:         return Response({"message": "Complete WhatsApp setup in settings"}, status=400)          access_token = whatsapp_business.access_token     product_catalog_id = whatsapp_business.catalog_id          if not all([access_token, product_catalog_id]):         return Response({"error": "Missing Access Token or Catalog ID"}, status=400)     # External API request (seems to be the timeout issue in production)     try:         product_feed_data = request.build_absolute_uri(reverse('get-product-feeds'))         response = requests.get(product_feed_data, params={             'access_token': access_token,             'product_catalog_id': product_catalog_id         })         response.raise_for_status()     except requests.RequestException as e:         return Response({'error': str(e)}, status=500)     # Other logic... (contains another call to graph api for uploading the new data feed) 

Troubleshooting Attempts:

  • Local vs. Production Testing: Locally, the endpoint works without issues.

  • Error Isolation: Confirmed the timeout is likely due to the Meta Products Feed API request.

What might cause a 504 Gateway Timeout when accessing the Meta Products Feed API in production, but not locally? Could this be due to server or network configuration differences, or specific Meta API requirements in production? Any advice on addressing API timeouts in Django would be helpful.

I am using Python and Facebook Graph API v17.0 to schedule image posts. I use scheduled_publish_time parameter when creating the post, also I am specifying published parameter to false. The problem I have is that the post is scheduled but it does not appear in the "facebook planner" (in meta bussines suite).

Even the post is not in the calendar, it is posted in the feed according to date and time specified in the code.

is there a way to access to a specified scheduled post (with the id) and check or edit manually (if is necessary) ?

I tryed with:

https://www.facebook.com/{page_id}/posts/{post_id}/

But it shows the post with the date and time when it was created not when the post should go live (scheduled date&time).

Do you know how to construct a link to access to a specific scheduled post that shows the date and time when it should go live (scheduled date&time)?

I hope someone can help.

Thanks in advance.

i got the access token but while exhangeing it for long live token api getting following error

error: { message: 'Unsupported request - method type: get', type: 'IGApiException', code: 100, fbtrace_id: 'AnMYrIXYSTKYCA_Sh2qKxkU' }

const accessTokenApi = {             url: 'https://api.instagram.com/oauth/access_token',             method: 'post',             headers: {                 'Content-Type': 'application/x-www-form-urlencoded'             },             body: new URLSearchParams({                 code: code,                 redirect_uri: instagramConfig.callbackUrl,                 client_id: instagramConfig.clientId,                 client_secret: instagramConfig.clientSecret,                 grant_type: 'authorization_code',             }).toString(),         };         const tokenResponse = await this.apiCall(accessTokenApi); const userPlatform = await this.userPlatformService.getUserPlatfromsByCode(userId, "INSTAGRAM");         const userLongLiveTokenApi = {             url:`https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret=${instagramConfig.clientSecret}&access_token=${userPlatform.authToken}`,             method: 'get',             headers:{}         }         console.log(userLongLiveTokenApi)         const userLongLiveTokenResponse = await this.apiCall(userLongLiveTokenApi);