انقطاع جزئي للخدمةshare-external
message:(#100) The parameter messaging_product is required
1

Hi experts I encountered an error when I sent a request to upload an image, error:map[code:100 fbtrace_id:Anl1AE-yMVtzsJlSwvxi6vP message:(#100) The parameter messaging_product is required. type:OAuthException

I refer to the examples provided in the official documentation, curl -X POST 'https://graph.facebook.com/v21.0/<PHONE_NUMBER_ID>/media' \ -H 'Authorization: Bearer <ACCESS_TOKEN>' \ -F 'file=@"2jC60Vdjn/cross-trainers-summer-sale.jpg"' \ -F 'type="image/jpeg"' \ -F 'messaging_product="whatsapp"'

My main code is shown as below,

body := &bytes.Buffer{} form := multipart.NewWriter(body) part, err := form.CreateFormFile("file", filepath.Base(imagePath)) _, err = io.Copy(part, file) err = form.WriteField("type", res.Header.Get("Content-Type")) err = form.WriteField("messaging_product", "whatsapp") err = form.Close()

req, err := http.NewRequest(http.MethodPost, uploadUrl, body) req.Header.Set("Content-Type", res.Header.Get("Content-Type")) req.Header.Set("messaging_product", "whatsapp") req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", accessToken))

client := &http.Client{Transport: tr} resp, err := client.Do(req)

Thanks for your attention and help.

Ming
تم طرح السؤال منذ حوالي شهر
Ming

Using the latest version of the API, refer to the following example to generate the code for Golang

‏٢٣ أكتوبر‏‏٧:٠٠ م‏111