I’m new to the facebook marketing API.
I was able to create a campaign.
But it seems I cannot create Adset.
I’ve tried posting with Javascript to the Adset:
https://graph.facebook.com/v2.8/act_156221465583672/adsets
with this payload:
var targeting = {
"age_max": 43,
"age_min": 18,
"geo_locations": { "countries": ["US"] }
};
var campaignId = "520337003094784508";
var promotedObject = {
'application_id': 2242592062246511
};
and post body:
{
"access_token": accessToken,
"name": "testNirAd",
"lifetime_budget": "8000",
"autobid": "true",
"start_time": new Date("October 13, 2017 00:00:00"),
"end_time": new Date("November 13, 2017 00:00:00"),
"optimization_goal": "POST_ENGAGEMENT",
"billing_event": "IMPRESSIONS",
"daily_budget": "2000",
"campaign_id": campaignId,
"targeting": JSON.stringify(targeting),
"status": "PAUSED"
}
But I get this error:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_data": {
"blame_field_specs": [
[
"name"
]
]
},
"error_subcode": 2061015,
"is_transient": false,
"error_user_title": "Required Field Is Missing",
"error_user_msg": "The name field is required. Please complete the
field to continue.",
"fbtrace_id": "HFg4HmwbQhG"
}
}
Which is strange because I have a name field.
Then I’ve tried the same with the Javascript SDK
https://github.com/lucascosta/facebook-js-ads-sdk, with the same payload data,
and this time I get:
{
code:1
fbtrace_id:”DcXmP0Wr82Q”
message:”An unknown error has occurred.”
type:”OAuthException”
}
Please can anybody help?
2
Answers
Tried also with different, less parameters, with Curl, and got the same results:
And got:
fbtrace_id: AeI4nngXTmj
By the way, I'm using a sandbox account.
Thanks!
I would recommend not posting the access tokens on public forums.
The error is most likely a formatting issue.
Easiest way to debug is to use the Graph API explorer tool, which lets you pick you app, generate the token, and define the parameters.
You can then get the curl code once you know the syntax is correct.
https://developers.facebook.com/tools/explorer/
Also, the code sample for creating app ads might help you, though it’s not JS.
https://www.facebookmarketingdevelopers.com/samples/app_install_ad