Join the Conversation!
We're interested in hearing what you have to say. Sign in with your Windows Live ID to leave comments or start new discussions.

Help with Creating Ad Group

This question is answered

I'm trying to create an Ad Group via the REST API and I'm getting the internal error message. Any help would be appreciated. Thanks.

URL: https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/CampaignManagementServiceREST.svc/customer/account/campaign/XXXXXXX/adGroup?format=json

Here is the encoded JSON

{\"AdGroups\":[{\"AdDistribution\":[\"Search\"],\"BiddingModel\":\"Keyword\",\"BroadMatchBid\":{\"amount\":0.05},\"ContentMatchBid\":{\"amount\":0.05},\"ExactMatchBid\":{\"amount\":0.05},\"Language\":\"English\",\"Name\":\"Test Group\",\"Network\":\"OwnedAndOperatedOnly\",\"PhraseMatchBid\":{\"amount\":0.05},\"PricingModel\":\"Cpc\",\"PublisherCountries\":[\"US\"]}]}

Response:

<AdApiFaultDetail xmlns="https://adapi.microsoft.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><TrackingId>cb54a5d6-9414-40bf-a840-1429086fb551</TrackingId><Errors><AdApiError><Code>0</Code><Detail i:nil="true"/><ErrorCode>InternalError</ErrorCode><Message>An internal error has occurred.</Message></AdApiError></Errors></AdApiFaultDetail>

Verified Answer
  • Hello.

    My colleague and I found a couple of issues with your initial JSON request string. Enumerations values such as Cpc should be specified as an int, e.g. "PricingModel":0. Additionally if you are specifying PublisherCountries, the structure should include Country and IsOptedIn elements, e.g. "PublisherCountries":[{"Country":"US","IsOptedIn":true}].

    Here is a full sample which works for me for v8 production.

    REQUEST_STRING = ('{"AdGroups":[{"AdDistribution":1,"BiddingModel":0,"BroadMatchBid":{"Amount":0.05},"CashBackInfo":null,"ContentMatchBid":{"Amount":0.05},"ExactMatchBid":{"Amount":0.05},"Id":null,"Language":"English","Name":"sample ad group","Network":1,"PhraseMatchBid":{"Amount":0.05},"PricingModel":0,"PublisherCountries":[{"Country":"US","IsOptedIn":true}]}]}')


    I hope this helps!

    Eric

  • I may not have answered your question completely the last time. There are no JSON samples provided in the adCenter API documentation. We do have XML samples here: https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/CampaignManagementServiceREST.svc/help I hope this helps!
All Replies
  • Hello.

    My colleague and I found a couple of issues with your initial JSON request string. Enumerations values such as Cpc should be specified as an int, e.g. "PricingModel":0. Additionally if you are specifying PublisherCountries, the structure should include Country and IsOptedIn elements, e.g. "PublisherCountries":[{"Country":"US","IsOptedIn":true}].

    Here is a full sample which works for me for v8 production.

    REQUEST_STRING = ('{"AdGroups":[{"AdDistribution":1,"BiddingModel":0,"BroadMatchBid":{"Amount":0.05},"CashBackInfo":null,"ContentMatchBid":{"Amount":0.05},"ExactMatchBid":{"Amount":0.05},"Id":null,"Language":"English","Name":"sample ad group","Network":1,"PhraseMatchBid":{"Amount":0.05},"PricingModel":0,"PublisherCountries":[{"Country":"US","IsOptedIn":true}]}]}')


    I hope this helps!

    Eric

  • Thanks Eric, it works.

    Could you point me towards some documentation regarding the specs for the JSON request for the REST API? I must have missed it or been looking at the wrong docs because this is the first time the correct specs.

  • Hello tpsoc,

    Sorry for our delayed response, you can find REST API documentation here: http://msdn.microsoft.com/en-US/library/ff728502.aspx

    Let us know if you have any futher questions! :-)

    Thanks!

    Ricky Poole - Web Support Specialist

    Twitter: Follow adCenter

  • Thanks for posting the link Ricky! Also be sure to take note of the request components noted within each service template. E.g. http://msdn.microsoft.com/en-us/library/ff728503.aspx (AddAdGroups REST Template) lists the following: For enumeration types, you must use numeric values instead of the value names defined in the value set. For example, to specify the Keyword value defined in the BiddingModel value set, set the BiddingModel element of the AdGroup object to 0 (zero) instead of to Keyword.
  • I may not have answered your question completely the last time. There are no JSON samples provided in the adCenter API documentation. We do have XML samples here: https://adcenterapi.microsoft.com/Api/Advertiser/v8/CampaignManagement/CampaignManagementServiceREST.svc/help I hope this helps!