Reputation: 11
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?
Upvotes: 1
Views: 2764
Reputation: 1
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
Upvotes: 0
Reputation: 11
Tried also with different, less parameters, with Curl, and got the same results:
curl /
-F 'name=MyFirstTest' /
-F 'billing_event=IMPRESSIONS' /
-F 'bid_amount=2' /
-F 'daily_budget=1000' /
-F 'campaign_id=120330000094784508' /
-F 'targeting={"geo_locations":{"countries":["US"]}}' /
-F 'start_time=2017-10-14T16:06:09+0000' /
-F 'end_time=2017-11-21T16:06:09+0000' /
-F 'status=PAUSED' /
-F 'access_token= EAAf0hSLb7osBAEgUpUtkGydJ9mmfZCzYumfNVxDFUjBFtx7C8aos3x
LbzjwkZBEbgXkWAT75OvIy6HXNTFBEqN1ca1aVvWT3RQAAKAAi6jYyncTG3m9ae0MkZAM9gZDZD'
/https://graph.facebook.com/v2.8/act_116221225224746/adsets
And got:
{"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":"AeI4nngXTmj"}}
fbtrace_id: AeI4nngXTmj
By the way, I'm using a sandbox account.
Thanks!
Upvotes: 0