In facebook marketing api leadgen_context_cards edge is not accepting cover_photo -


i following https://developers.facebook.com/docs/marketing-api/guides/lead-ads/create/v2.8 create context card lead ad. document says accept cover_photo field. if try create context graph api explorer following params

https://developers.facebook.com/tools/explorer/xxxxxx?method=post&path=<page_id>%2fleadgen_context_cards&version=v2.8&title=sample-title-1&style=paragraph_style&content=[%22sample%20content%201%22]&button_text=get%20started&cover_photo=http://xxxxx.s3.amazonaws.com/sample/sampleimage.png 

its showing following

{   "error": {     "message": "an unknown error has occurred.",     "type": "oauthexception",     "code": 1,     "fbtrace_id": "xxxxxx"   } } 

and if click on fgtrace_id showing following

{   "error": {     "message": "(#803) of aliases requested not exist: xxxxx",     "type": "oauthexception",     "code": 803,     "fbtrace_id": "yyyyyy"   } } 

if remove cover_photo param able create context cards.

thanks.

update 1

i have tried upload actual image file. still facing same issue. following code , response.

        httpclient httpclient = httpclientbuilder.create().build();         httppost httppost = new httppost(graph_facebook_leadgen_context_cards);          file file = new file(image_path);         contentbody cbfile = new filebody(file, contenttype.create(mimetypeutils.image_png_value));          multipartentitybuilder builder = multipartentitybuilder.create();         builder.addtextbody("access_token", access_token);         builder.addtextbody("title", "sample-title-1");         builder.addtextbody("style", "paragraph_style");         builder.addtextbody("content", "['sample-title-1']");         builder.addtextbody("button_text", "get started");     // builder.addpart("cover_photo", cbfile);     // builder.addbinarybody("cover_photo", file);     // builder.addbinarybody("cover_photo", file, contenttype.create(mimetypeutils.image_png_value),image_path);     // builder.addbinarybody("cover_photo", new fileinputstream(file));      httppost.setentity(builder.build());     system.out.println("executing request " + httppost.getrequestline());     httpresponse response = httpclient.execute(httppost);     httpentity resentity = response.getentity();      system.out.println(response.getstatusline());     if (resentity != null) {         system.out.println(entityutils.tostring(resentity));     } 

response:

executing request post https://graph.facebook.com/167067040143315/leadgen_context_cards http/1.1 http/1.1 500 internal server error {"error":{"message":"an unknown error has occurred.","type":"oauthexception","code":1,"fbtrace_id":"chg1sydq9zn"}} 

update 2

with following code able create context card. cover photo missing.

uribuilder uribuilder = new uribuilder(                 graph_facebook_leadgen_context_cards);         uribuilder.setparameter("access_token", access_token);         uribuilder.setparameter("title", "sample-title-1");         uribuilder.setparameter("style", "paragraph_style");         uribuilder.setparameter("content", "['sample-title-1']");         uribuilder.setparameter("button_text", "get started");         httpclient httpclient = httpclientbuilder.create().build();         httppost httppost = new httppost(uribuilder.build());          file file = new file(image_path);         contentbody cbfile = new filebody(file,                 contenttype.create(mimetypeutils.image_png_value));         byte[] bytes = fileutils.readfiletobytearray(file);          multipartentitybuilder builder = multipartentitybuilder.create();          builder.addpart("cover_photo", cbfile);         // builder.addbinarybody("cover_photo", file);         // builder.addbinarybody("cover_photo", file,         // contenttype.create(mimetypeutils.image_png_value),image_path);         // builder.addbinarybody("cover_photo", new fileinputstream(file));         // builder.addbinarybody("cover_photo", bytes,         // contenttype.create(mimetypeutils.image_png_value),image_path);          httppost.setentity(builder.build());         httppost.addheader(new basicheader("content-type",                 contenttype.multipart_form_data.getmimetype()));         system.out.println("executing request " + httppost.getrequestline());         httpresponse response = httpclient.execute(httppost);         httpentity resentity = response.getentity();          system.out.println(response.getstatusline());         if (resentity != null) {             system.out.println(entityutils.tostring(resentity));         } 

as per observation in https://business.facebook.com's ui. first uploading image , passing id in cover_photo_id.

uploaded unpublished photo page/photos , passed generated id in context_card's cover_photo_id. , worked.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -