我正在将post
请求发送到点击支付网关以保存卡,url
需要两个参数,比如一个是源(最近生成的令牌),在url
的{customer_id}
内,我正在尝试string
连接,但它显示了错误,比如无效的JSON
请求
视图。py:
ifCustomerExits = CustomerIds.objects.filter(email=email)
totalData = ifCustomerExits.count()
if totalData > 1:
for data in ifCustomerExits:
customerId = data.customer_id
print("CUSTOMER_ID CREATED ONE:", customerId)
tokenId = request.session.get('generatedTokenId')
payload = {
"source": tokenId
}
headers = {
'authorization': "Bearer sk_test_XKokBfNWv6FIYuTMg5sLPjhJ",
'content-type': "application/json"
}
# HERE DOWN IS THE url of TAP COMPANY'S API:
url = "https://api.tap.company/v2/card/%7B"+customerId+"%7D"
response = requests.request("POST", url, data=payload, headers=headers)
json_data3 = json.loads(response.text)
card_id = json_data3["id"]
return sponsorParticularPerson(request, sponsorProjectId)
他们期望的url=https://api.tap.company/v2/card/{customer_id}
他们的文档链接:https://tappayments.api-docs.io/2.0/cards/create-a-card
试试这个。。 第一次转换
dict
。进入JSON
并使用request.post
发送post
请求:请告诉我这是否有效
相关问题 更多 >
编程相关推荐