"call_to_action_type field in creative is required in this ad" returned while creating ads using marketing api - facebook

When I use adcreatives endpoint with object_story_spec parameter to create ads or using object_story_id parameter following instructions in this link :
I got this error message:
{"error":{"message":"Invalid
parameter","type":"FacebookApiException","code":100,"error_subcode":1487664,"is_transient":false,"error_user_title":"Missing
Call To Action Type","error_user_msg":"call_to_action_type field in
creative is required in this ad"}}
Anyone knows how to solve this problem?

Are you not setting the call_to_action field? While it's not explicitly stated in the docs (as far as I can see) the field is mentioned for all ads for mobile app install or engagement campaigns so I suggest setting it.
https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.2#cta_definitions

Related

Facebook Insights API not returning store visits data

I am trying to retrieve Store Visits data from the Facebook Insights API. Based on their documentation, these should be available by specifying the following parameters:
store_visit_actions
cost_per_store_visit_actions
When I use store_visit_actions as a parameter, no data is returned. I know data exists because it is displayed through their UI reporting tool.
When I use cost_per_store_visit_actions, I receive a 100 invalid param error:
cost_per_store_visit_actions is not valid for fields param.
These params are listed as "In Development", however, I'm retrieving other development parameters without issue. Is anyone facing the same issue or know how to fix?
this is because the metrics
store_visit_actions
cost_per_store_visit_actions
are deprecated in facebook api v11.0. You can checkout this link:
https://developers.facebook.com/docs/graph-api/changelog/version11.0/

Provide array of URNs to LinkedIn REST API?

I am using the LinkedIn Marketing Development Platform where I am trying to provide a list of company URNs to to the Ad Analytics API. However, when I try to provide a list of company URNs, it fails with status 400.
Analytics Finder endpoint docs
My request:
GET https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2017&timeGranularity=ALL&companies=urn:li:organization:1234,urn:li:organization:5678
Response:
{"message":"Array parameter 'companies' value 'urn:li:organization:1234,urn:li:organization:5678' is invalid. Reason: Deserializing output 'urn:li:organization:1234,urn:li:organization:5678' failed","status":400}
I have also tried URL encoding the URL, and providing the list via the parameter companies[0] as is done in other examples in the docs.
What is the correct way to input arrays to the LinkedIn API?
Edit: Changed accounts to companies
So the Protocol Version actually gave me some useful insight. There are a couple of ways of providing arrays in parameters.
From the docs:
For Restli V1.0 (used by default)
GET GET https://api.linkedin.com/people?ids=1&ids=2&ids=3
For Restli V2.0, which you can use by setting the following header: X-RestLi-Protocol-Version: 2.0.0
Pass parameters in List format.
GET https://api.linkedin.com/v2/people?ids=List(1,2,3,4)
However, I have not managed to get the Analytics Finder API to work with Restli V2.0.
You'll need to provide the list of URL encoded organization URNs to the accounts param. Using your request as an example:
&accounts=List(urn%3Ali%3Aorganization%3A1234,urn%3Ali%3Aorganization%3A5678)

How to create a Facebook ad based on a post?

After many tries, I'm not getting how we can use the Facebook API to create a simple Ad based on a Post (and it's creative) like it is possible in the Business Manager.
For example, my last attempt failed due to a problem with Instagram:
Facebook API: Instagram Account Is Missing
If there is anybody that has been able to create a basic Ad (within a given or new AdSet) based on a Post, please help me. I've seen many questons like this (especially regarding the Instagram problem) and now I'd like to have a working solution.
What exact requests have to be done or isn't it possible at all?
THe Instagram placement is added by default in the targeting, so if you want to skip it you need to specify in the targeting field when creating the adSet in the publisher field:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook'],
facebook_positions: ['feed', 'right_hand_column'],
device_platforms: ['mobile', 'desktop']
}
If you want to publish on Instagram also you should also provide an instagram actor ID: The AdsCreative should contain an extra field named instagram_actor_id also remember to add Instagram in the related targeting:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook','instagram'],
facebook_positions: ['feed', 'right_hand_column'],
instagram_positions: ['stream', 'story'],
device_platforms: ['mobile', 'desktop']
}
Reference:
https://developers.facebook.com/docs/marketing-api/guides/instagramads
https://developers.facebook.com/docs/marketing-api/guides/instagramads/ads_management/
https://developers.facebook.com/docs/marketing-api/targeting-specs/#placement
Let me know if you need more info or an answer or your other question about Instragam

Facebook marketing api access non existing field

I am trying to access campaigns of the facebook account. Using python lib: https://github.com/facebook/facebook-python-ads-sdk
Receive error: (#100) Tried accessing nonexisting field (campaigns) on node type (AdAccount)
Url: https://graph.facebook.com/v2.11/{account_id}/campaigns
Everything worked fine for months. Now, even facebook page for this url is empty: https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/
Any thoughts, what's the problem?
Seems to be a bug.
Reported here: https://developers.facebook.com/bugs/707332642990208/
Works perfectly without time_range param.
So, could be temporary solution.
I don't know if this is a bug or not: facebook does this from time to time and is implementing check routines for parameters - in fact "adaccounts don't have any parameters:facebook api reference adaccount reading)
The error you are getting (#100) says "invalid parameter" (facebook reference adaccount validation rules), this is, because you may have defined the time_range and you are asking api for campaigns in an adaccount. But: for adaccount edge time_rage parameter is invalid.
The solution is to FIRST asking api for https://graph.facebook.com/v2.11/{account_id}/campaigns and after this defining the (time_range) parameter(s) for the insights of your campaign.

An unknown error has occurred on Graph Facebook

I tried to get Data from Facebook Page with the graph of Facebook but I have a problem.
When I try to go on link like:
https://graph.facebook.com/ID-PAGE?access_token=MY_ACCESS_TOKEN
I always do this to have the Data from a Page but since today I have the error Message: "An unknown error has occurred".
Thanks for help.
EDIT:
The bug is fixed : https://developers.facebook.com/bugs/486654544831076/?search_id
Have a look at my answer at
How to get user email and birthday from Facebook API Version v2.4
You have to specify each field you want to query now with v2.4. If you want to explicitly use v2.3, you need to prepend your calls by /v2.3 like this:
/v2.3/{page_id}?access_token=MY_ACCESS_TOKEN
Seems like there's currently a bug regarding requests made with app access tokens instead of user access tokens:
https://developers.facebook.com/bugs/486654544831076/
At this moment, I pretty much figured out what is happening, and it looks like a bug in the Facebook API.
For v2.3 and lower:
The /PAGE-ID call will return an Unknown server error when you don't pass ?fields=username (for example). If you do pass the fields option, it will work. You can get it out of the docs.
For v2.4:
This will work, but you will miss a lot of data, so you'll also have to pass the fields options. But if you don't pass that, this version will give you back only the most basic of details. This is as described in the version release: https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
So the solution for now, would be to add the ?fields= everywhere you need, or to wait for Facebook to maybe ever solve it.
(And while you're at it, you might as well upgrade to v2.4 ;-)