FeedItemService: Try to add a new feed item causes [EntityNotFound.INVALID_ID @ operations[0].operand.feedId]

371 views
Skip to first unread message

Alex Schäfer

unread,
Jun 4, 2014, 12:04:10 PM6/4/14
to adwor...@googlegroups.com
Hi group,

when I try to add a new FeedItem with FeedItemService I get the error that my feedId is invalid. We have only one feed in the system and the id is correct. (FeedService or AdGroupFeedService returns this id). Updating FeedItems works perfect. Hope you can help me :)

Request:
<ns1:operations>
        <ns1:operator>ADD</ns1:operator>
        <ns1:operand>
          <ns1:feedId>11874994</ns1:feedId>
          <ns1:status>ACTIVE</ns1:status>
          <ns1:startTime>20140616 000000</ns1:startTime>
          <ns1:endTime>20141029 235959</ns1:endTime>
          <ns1:attributeValues>
            <ns1:feedAttributeId>1</ns1:feedAttributeId>
            <ns1:stringValue>Test1</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>2</ns1:feedAttributeId>
            <ns1:stringValue>http://www.test2.de</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>5</ns1:feedAttributeId>
            <ns1:stringValue>descrp1</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>6</ns1:feedAttributeId>
            <ns1:stringValue>descrp1</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:devicePreference/>
        </ns1:operand>
      </ns1:operations>

Response:

<soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>[EntityNotFound.INVALID_ID @ operations[0].operand.feedId]</faultstring>
      <detail>
        <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201402">
          <message>[EntityNotFound.INVALID_ID @ operations[0].operand.feedId]</message>
          <ApplicationException.Type>ApiException</ApplicationException.Type>
          <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="EntityNotFound">
            <fieldPath>operations[0].operand.feedId</fieldPath>
            <trigger/>
            <errorString>EntityNotFound.INVALID_ID</errorString>
            <ApiError.Type>EntityNotFound</ApiError.Type>
            <reason>INVALID_ID</reason>
          </errors>
        </ApiExceptionFault>
      </detail>
    </soap:Fault>

Thanks

Alex

Josh Radcliff (AdWords API Team)

unread,
Jun 5, 2014, 9:22:47 AM6/5/14
to adwor...@googlegroups.com
Hi Alex,

I looked up your request and noticed that you are not setting the clientCustomerId in your SOAP header. As a result, the API will attempt to back into the effective account from your credentials. If you are using credentials from an MCC account then the feed with that ID will not exist in the effective account (assuming your feed is in an AdWords account, not your MCC). Setting the customer ID to the actual AdWords client account should resolve this.

Cheers,
Josh, AdWords API Team

Alex Schäfer

unread,
Jul 2, 2014, 2:16:11 PM7/2/14
to adwor...@googlegroups.com
Hi Josh,

thank you for the response and sorry for my late feedback.
Meantime it works and I don't know why. Know I have the same problem again. I'm using the "AddSitelinks" Example in PHP Adwords Lib Version 5.2.3.

Thanks,
Alex

Alex Schäfer

unread,
Jul 2, 2014, 2:20:50 PM7/2/14
to adwor...@googlegroups.com
Here is a snippet of my php method for better understanding:

    public function addSitelink(AdWordsUser $user, $data)
    {

        $user->LogAll();

        $result = array('success' => true);

        $feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION);

        $startDate = DateTime::createFromFormat('Y-m-d H:i:s', $data['start_time']);
        $endDate =  DateTime::createFromFormat('Y-m-d H:i:s', $data['end_time']);

        // Create new feed item
        $feedItem = new FeedItem();
        /*$feedItem->feedItemId = !empty($data['external_id']) ? $data['external_id'] : null;*/
        $feedItem->feedId = intval($data['external_feed_id']);
        $feedItem->status = $data['status'];
        $feedItem->startTime = $startDate->format('Ymd His');
        $feedItem->endTime = $endDate->format('Ymd His');
        $feedItem->devicePreference = $data['device_preference'];

        $itemAttributeValues = array();

        // Assign Attributes
        foreach ($data['attributes'] as $attribute) {
            $itemAttributeValue = new FeedItemAttributeValue();
            $itemAttributeValue->stringValue = $attribute['value'];
            $itemAttributeValue->feedAttributeId = $attribute['external_feed_attribute_id'];
            $itemAttributeValues[] = $itemAttributeValue;
        }

        $feedItem->attributeValues = $itemAttributeValues;
        $itemOperations[] = new FeedItemOperation($feedItem, 'ADD');

        try {
            $response = $feedItemService->mutate($itemOperations);
            $result['response'] = $response->value[0];
        } catch (Exception $e) {
            // process error
            $result['success'] = false;
            $result['errors'][] = $this->getErrorMessage($e);
            return $result;
        }
        
     .....
     .....
     // Do some more stuff
}

Alex Schäfer

unread,
Jul 2, 2014, 2:29:47 PM7/2/14
to adwor...@googlegroups.com
Ok sorry. In my first post I didn't paste the complete request:

<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Header>
    <ns1:RequestHeader>
      <ns1:developerToken>123456</ns1:developerToken>
      <ns1:userAgent>TestMCC (AwApi-PHP/5.2.3, Common-PHP/5.2.3, PHP/5.4.24)</ns1:userAgent>
    </ns1:RequestHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:mutate>
      <ns1:operations>
        <ns1:operator>ADD</ns1:operator>
        <ns1:operand>
          <ns1:feedId>11874994</ns1:feedId>
          <ns1:status>ACTIVE</ns1:status>
          <ns1:startTime>20140501 000000</ns1:startTime>
          <ns1:endTime>20140516 235959</ns1:endTime>
          <ns1:attributeValues>
            <ns1:feedAttributeId>1</ns1:feedAttributeId>
            <ns1:stringValue>Test1</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>2</ns1:feedAttributeId>
            <ns1:stringValue>http://www.test.de</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>5</ns1:feedAttributeId>
            <ns1:stringValue>desrcp1</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:attributeValues>
            <ns1:feedAttributeId>6</ns1:feedAttributeId>
            <ns1:stringValue>descrp2</ns1:stringValue>
          </ns1:attributeValues>
          <ns1:devicePreference/>
        </ns1:operand>
      </ns1:operations>
    </ns1:mutate>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Josh Radcliff (AdWords API Team)

unread,
Jul 7, 2014, 1:11:33 PM7/7/14
to adwor...@googlegroups.com
Hi Alex,

I looked up your failed requests in our logs again and noticed that they still did not include the clientCustomerId SOAP header, so AdWords will try to locate the Feed (by ID) in the AdWords account associated with your OAuth2 access token. If that account is your MCC then it won't find the Feed.

Please try setting the clientCustomerId SOAP header to the AdWords account and let me know if you still see this problem.

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages