0
類型錯誤不是一個有效非字符串序列或映射對象:不是一個有效非字符串序列或映射對象 •與數據構造的數據字典和使用json.dumps •發佈請求一起類型錯誤:
data = {
"filter": "'{{Activity.Type}}'='Bounceback'",
"name": "Bulk Activity Export - Bounceback",
"fields": {
"ActivityId": "{{Activity.Id}}"
}
}
data = json.dumps(data)
print(request.post("/activities/exports", data = data))
POST請求方法(這是不完整的碼,只是它執行交請求的部分)
def post(self, url, data):
return self.request('POST', url, data)
print(request)
if data != None:
data = urllib.urlencode(data)
結果:
認證沒有問題。這是請求對象和http頭。我得到TypeError:不是有效的非字符串序列或映射對象錯誤。
data object: {"filter": "'{{Activity.Type}}'='Bounceback'", "fields": {"AssetType": "{{Activity.Asset.Type}}", "ActivityId": "{{Activity.Id}}", "EmailAddress": "{{Activity.Field(EmailAddress)}}", "AssetId": "{{Activity.Asset.Id}}", "ActivityDate": "{{Activity.CreatedAt}}", "AssetName": "{{Activity.Asset.Name}}", "CampaignId": "{{Activity.Campaign.Id}}", "ExternalId": "{{Activity.ExternalId}}", "ActivityType": "{{Activity.Type}}"}, "name": "Bulk Activity Export - Bounceback"}
頁眉:
{'Content-Type': 'application/json', 'Authorization': 'Basic RmlhdE1hcmtldGluZ1xGMzIwMDJCOkFjY2V'}