2017-02-21 97 views
0

我有一個泡沫對象:Python Adwords API suds.sudsobject解析包含空索引鍵的響應?

<class 'suds.sudsobject.AdGroupPage'> 

肥皂水響應:

(AdGroupPage){ 
    totalNumEntries = 1 
    Page.Type = "AdGroupPage" 
    entries[] = 
     (AdGroup){ 
     id = 38496562285 
     campaignId = 759990659 
     campaignName = "Some Campaign #1" 
     name = "Second group" 
     status = "ENABLED" 
     biddingStrategyConfiguration = 
      (BiddingStrategyConfiguration){ 
       biddingStrategyType = "MANUAL_CPC" 
       bids[] = 
        (CpcBid){ 
        Bids.Type = "CpcBid" 
        bid = 
         (Money){ 
          ComparableValue.Type = "Money" 
          microAmount = 1230000 
         } 
        cpcBidSource = "ADGROUP" 
        }, 
      } 
     }, 
} 

我試圖創建一個谷歌的Adwords API一個SET操作來改變使用AdWords API的廣告組出價別的東西變異操作。

這是我在PYTHON嘗試:

operations = [{ 
    'operator': 'SET', 
    'operand': { 
     'id': 38496562285, 
     'biddingStrategyConfiguration': { 
      'bids': [{ 
       'bid': { 
        'microAmount': 4560000 
        } 
       }] 
      } 
     } 
    }] 

從我的要求的錯誤是:

suds.TypeNotFound: Type not found: 'bid' 

這裏有一個簡單的例子,成功的作品:

operations = [{ 
     'operator': 'SET', 
     'operand': { 
      'id': ad_group_id, 
      'status': 'PAUSED' 
     } 
    }] 

我的問題是,我沒有k現在如何處理來自泡沫響應的bids[]語法。我應該如何修改我的字典以使用空列表鍵?

回答

0

看起來我必須包含一些名爲xsi_type的東西。在情況下任何人碰到這個問題絆倒,這是我的operations物體看起來像:

operations = [{ 
     'operator': 'SET', 
     'operand': { 
     'id': 38496562285, 
     'biddingStrategyConfiguration': { 
      'bids': [{ 
      'xsi_type': 'CpcBid', 
      'bid': {'microAmount': 4560000} 
      }] 
      } 
     } 
     }] 

這裏是v201609 AdGroupService.BiddingStrategyConfiguration的鏈接。它沒有提到xsi_type,但是如果您遇到像bids[]這樣的字段,則您現在知道在您的操作中嘗試定義xsi_type