TypeError:不是有效的非字符串序列或映射对象

时间:2016-05-03 07:29:01

标签: python http post eloqua

TypeError:不是有效的非字符串序列或映射对象 •构造了数据字典并使用了json.dumps •发布请求和数据

LinearLayoutManager linearLayoutManager = new LinearLayoutManager( getActivity() );                     
linearLayoutManager.setOrientation( LinearLayoutManager.VERTICAL );
linearLayoutManager.setAutoMeasureEnabled( true );

邮政请求方法(这不是完整的代码,只是执行邮件请求的部分)

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

结果:

身份验证没有问题。这是请求对象和http标头。我得到TypeError:不是有效的非字符串序列或映射对象错误。

def post(self, url, data):
    return self.request('POST', url, data)

print(request)
if data != None:
   data = urllib.urlencode(data)

标题:

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"}

1 个答案:

答案 0 :(得分:0)

See herehere

我不是Python专家,但这个问题与Eloqua无关,而与Python有关。您似乎手动创建了定义,您可以尝试手动创建字典而不是使用json.dumps

我希望这个基本身份验证令牌是假的,而不是有人会轻易登录你的Eloqua。