【发布时间】:2022-10-30 07:10:49
【问题描述】:
我正在通过 Safaricom 在线实施 Lipa na M-Pesa。但是,当我提出请求时,我收到一条错误消息,提示检测到重复的 json 键。
有效载荷:
payload = {
"BusinessShortCode": 174379,
"Password": "the password",
"Timestamp": "20220817050503",
"TransactionType": "CustomerPayBillOnline",
"Amount": 5,
"PartyA": 254714895622,
"PartyB": 174379,
"PhoneNumber": 254714895622,
"CallBackURL": "https://58fa-102-68-78-50.in.ngrok.io/api/v1/payments/callback/",
"AccountReference": "Payment",
"TransactionDesc": "Payment for K"
}
标题:
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer access_token",
}
请求:
response = requests.request("POST", 'https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest', headers=headers, data=payload)
我得到的回应:
{
'responseId': '82699-21939686',
'responseCode': '400',
'responseDesc': 'Duplicate json key detected'
}
此错误的原因可能是什么,我该如何解决?
【问题讨论】:
标签: json python-3.x django django-rest-framework