Hi!
I have a problem with creating extensions on account level through the API (v201603, PHP).
In new account where there are no structured snippet extensions I am creating new feed for structured snipped extensions and new extension in it and on Campaigns / Ad Extensions screen I don't see it in account. Also I get this error:
"There was an error with your operation. If you were trying to make a change, it may not have saved. Please refresh this page to try again.
If the error continues, log out of your AdWords account, then log in again and return to this page. "
Here is the workflow:
First I search for existing feeds through the API, here is my AWQL query:
SELECT Id, Name, Attributes WHERE FeedStatus="ENABLED" AND Name IN ["_Main structured snippet feed", "Main structured snippet feed"]
I get nothing.
When I try to create "_Main structured snippet feed" I get FeedError.INVALID_FEED_NAME.
But when I create it without "_" at first all seems fine and the feed and extension are created successfully, but I get this error "There was an error with your operation..."
http://screencloud.net/v/2Fz5 on the Campaigns / Ad extensions screen (
http://screencloud.net/v/i6d9)
And the extension is not visible in this tab.
But when I try to create new extension manually in the default feed - I see both feeds
http://screencloud.net/v/tSc5, and after creating it in "_Main..." account - it is available, but "Main..." account created through the api seems broken:
http://screencloud.net/v/nlUaIf there are already at least one extension in "_Main..." feed - it is available through the API and everything is fine. But in new accounts when there are no extensions this feed is unavailable, but seems like existing and hidden.
Here is this extension feed in Shared Library:
http://screencloud.net/v/x69phttp://screencloud.net/v/50ECAnd I don't see any difference with the extension I created manually through the adwords interface:
http://screencloud.net/v/ukt3http://screencloud.net/v/p0WtCan somebody explain what am I doing wrong or how can I retrieve default "_Main structured snippet feed" when there are no extensions in it?
Here is my Php code for creating feed and structured snippet extension:
// Get the FeedService, which loads the required classes.
$feedService = $user->GetService('FeedService', self::ADWORDS_VERSION);
$attributeName = self::EXT_SNIPPET_ATTRIBUTE_NAME;
$placeholderType = self::EXT_PLACEHOLDER_SNIPPET;
// Create attributes.
$textAttribute = new \FeedAttribute();
$textAttribute->type = 'STRING';
$textAttribute->name = $attributeName;
// Create the feed.
$feed = new \Feed();
$feed->name = $feedName;
$feed->attributes = [$textAttribute];
$feed->origin = 'USER';
// Additional snippet fields
$valueAttribute = new \FeedAttribute();
$valueAttribute->type = 'STRING_LIST';
$valueAttribute->name = self::EXT_SNIPPET_ATTRIBUTE_NAME_ADDITIONAL;
$feed->attributes[] = $valueAttribute;
// Create operation.
$operation = new \FeedOperation();
$operation->operator = 'ADD';
$operation->operand = $feed;
$operations = [$operation];
// Add the feed.
$result = self::mutate($feedService, $operations);
$savedFeed = $result->value[0];
// now we need to map this feed according to $type
$feedMappingService = $user->GetService('FeedMappingService', self::ADWORDS_VERSION);
// Map the FeedAttributeIds to the fieldId constants.
$textFieldMapping = new \AttributeFieldMapping();
$textFieldMapping->feedAttributeId = $savedFeed->attributes[0]->id;
$textFieldMapping->fieldId = 1;
$feedMapping = new \FeedMapping();
$feedMapping->placeholderType = $placeholderType;
$feedMapping->feedId = $savedFeed->id;
$feedMapping->attributeFieldMappings = [$textFieldMapping];
$operation = new \FeedMappingOperation();
$operation->operand = $feedMapping;
$operation->operator = 'ADD';
$operations = [$operation];
// Save the field mapping.
$result = self::mutate($feedMappingService, $operations);