Structured Snippet / Callout Ad Extension creating issue. "There was an error with your operation..."

109 views
Skip to first unread message

Alex L.

unread,
May 18, 2016, 9:12:06 AM5/18/16
to AdWords API Forum
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/nlUa
If 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/x69p
http://screencloud.net/v/50EC
And I don't see any difference with the extension I created manually through the adwords interface:
http://screencloud.net/v/ukt3
http://screencloud.net/v/p0Wt

Can 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);


Peter Oliquino

unread,
May 18, 2016, 2:33:30 PM5/18/16
to AdWords API Forum
Hi Alex,

Could you send me your soap logs? Please reply privately to author for the logs.

Thanks,
Peter
AdWords API Team

Alex L.

unread,
May 20, 2016, 10:26:57 AM5/20/16
to AdWords API Forum

Hi Peter.
The problem is that I don't get any Soap Exceptions and mutate result is valid:
http://screencloud.net/v/oO3y
p.s: sorry I do not quite well understand how the soap logging works; after initializing user object I am running $user->LogAll(); but no logs appear in my <root>/logs directory (rights are 777). So the only errors I get is from thrown Soap exceptions.
Btw here is the error I get when I try to create "_Main structured snippet feed":
https://screencloud.net/v/8UTZ

среда, 18 мая 2016 г., 21:33:30 UTC+3 пользователь Peter Oliquino написал:

Peter Oliquino

unread,
May 20, 2016, 2:32:48 PM5/20/16
to AdWords API Forum
Hello Alex,

You could activate the SOAP logs using this guide. You could send me SOAP logs privately using reply privately to author while responding.

Cheers,
Peter
AdWords API Team

Peter Oliquino

unread,
May 23, 2016, 11:53:52 AM5/23/16
to AdWords API Forum
Hello Alex,

I did some investigation and it appears that although it is allowed in the UI, a validation within the API does not allow having "_" as the first character for feedName. As a workaround, you may start your feedName string using alpha characters.

Regards,
Peter
AdWords API Team

Alex L.

unread,
May 23, 2016, 12:29:25 PM5/23/16
to AdWords API Forum
Peter,
Thanks for that information but it is not my problem.
Sorry I think I badly explained it: all of the feeds I am creating ("Main structured snippet feed" or "Lorem Ipsum Feed" or else) seems broken when I try to use them from Campaigns / Ad Extensions tab (https://screencloud.net/v/i6d9). When I choose the feed I have created through the API I get the error "There was an error with your operation..." in the top of my screen. But when I view it through the Shared Library / Business Data section (https://screencloud.net/v/x69p) everything seems fine and I don't see any differences between my API-created feed / extension and feed / extension that I create through the adwords interface manually. The worst thing is that I don't get any errors from the API response so I can't find if there were any mistakes in my code or something else.
Why I was talking about the "_Feed name" is that when you have clean adwords account and create your first structured snippet extension adwords creates default feed with the name "_Main structured snippet extension". It seems like the default main feed for this type of extensions which I would like to use, but I can get it through the API only when there was already created at least one extension. Until then it is not visible / not exist. That's why before adding new extension I need to create new feed. And after creating it I am facing this error.
So I need to figure out why my feed seems broken and what is causing this error to appear.
Sorry for this confusion, hope now I explained it more clear.
Hearing from you,
Alex
понедельник, 23 мая 2016 г., 18:53:52 UTC+3 пользователь Peter Oliquino написал:

Joyce Lava

unread,
May 23, 2016, 5:35:03 PM5/23/16
to AdWords API Forum
Hi Alex,

Structure Snippet Feed can be created by using FeedService and ExtensionSettingService. I saw in your code that you're using the FeedService to create it. However, you're missing the part where you need to map the feed to placeholder fields

You need to use PlaceHolderType ID as 24 for Structured Snippet Feed using FeedService. You may also refer on the ExtensionSettingService example. Please let me know if the problem is resolved after trying these.

Thanks and Regards,
Joyce, AdWords API Team

Alex L.

unread,
May 24, 2016, 2:38:12 AM5/24/16
to AdWords API Forum

Hi Jouyce,
I'm not missing it, here is this part from my example:


// 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);
(I store placeholder types in constants which I then assign to variable $placeholderType).
I create extension with first request and then I create mapping with second because I need feed ID which I get from result:

$result = self::mutate($feedService, $operations);
$savedFeed
= $result->value[0];
That is standard approach, just wanted to clarify that I am doing it as well.
Thanks for your reply but unfortunately this is not the case.
Alex

вторник, 24 мая 2016 г., 0:35:03 UTC+3 пользователь Joyce Lava написал:

Joyce Lava

unread,
May 24, 2016, 12:36:38 PM5/24/16
to AdWords API Forum
Hi Alex,

Sorry for the confusion.

I take a look on your codes once again and saw that your doing the FeedMapping for attributeId 1 only.  Based on the documentation, there is feedAttributeId "2" that you need to create for feedMapping as well.

You are making the "header" attribute which are pre-defined (Types, Brands, etc.). However, you need to create also the "values" to show those information.

Using Java client example, I was able to create the Structured Snippet successfully. I did the following code to do the mapping of FeedAttributeIds:

    // Map the FeedAttributeIds to the fieldId constants.
    AttributeFieldMapping headerFieldMapping = new AttributeFieldMapping();
    headerFieldMapping.setFeedAttributeId(structuredSnippetData.headerFeedAttributeId);
    headerFieldMapping.setFieldId(PLACEHOLDER_FIELD_STRUCTURED_SNIPPET_HEADER); //PLACEHOLDER_FIELD_STRUCTURED_SNIPPET_HEADER = 1
    AttributeFieldMapping valuesFieldMapping = new AttributeFieldMapping();
    valuesFieldMapping.setFeedAttributeId(structuredSnippetData.valuesFeedAttributeId);
    valuesFieldMapping.setFieldId(PLACEHOLDER_FIELD_STRUCTURED_SNIPPET_VALUES); //PLACEHOLDER_FIELD_STRUCTURED_SNIPPET_VALUES = 2

    // Create the FeedMapping and operation.
    FeedMapping feedMapping = new FeedMapping();
    feedMapping.setPlaceholderType(PLACEHOLDER_STRUCTURED_SNIPPET);
    feedMapping.setFeedId(structuredSnippetData.structureSnippetFeedId);
    feedMapping.setAttributeFieldMappings(new AttributeFieldMapping[] {headerFieldMapping,
        valuesFieldMapping});
    FeedMappingOperation operation = new FeedMappingOperation();
    operation.setOperand(feedMapping);
    operation.setOperator(Operator.ADD);

From the PHP code example, you may refer from line 170 to line 194.

This means that you need to create feedMapping for attributeId 1 and attributeId 2 to create structured snippet successfully.

Please let me know if this explains the solution on your case.

Alex L.

unread,
May 25, 2016, 5:08:40 AM5/25/16
to AdWords API Forum
Hi Joyce,
Thanks, that solved the problem!
I should have read documentation more carefully,
As for my code example if someone will need it, here is the part I missed:
// 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];

// additional field mapping attributes
if (self::EXT_SNIPPET == $type) {
    $textFieldMapping2
= new \AttributeFieldMapping();
    $textFieldMapping2
->feedAttributeId = $savedFeed->attributes[1]->id;
    $textFieldMapping2
->fieldId = 2;
    $feedMapping
->attributeFieldMappings[] = $textFieldMapping2;

}

$operation
= new \FeedMappingOperation();
$operation
->operand = $feedMapping;
$operation
->operator = 'ADD';
$operations
= [$operation];
Thanks again!


вторник, 24 мая 2016 г., 19:36:38 UTC+3 пользователь Joyce Lava написал:

Joyce Lava

unread,
May 25, 2016, 8:50:38 AM5/25/16
to AdWords API Forum
Hi Alex,

Glad to hear that it worked correctly.

Cheers,
Joyce, AdWords API Team
Reply all
Reply to author
Forward
0 new messages