尝试通过PayPal API上传文件证据时,获取INVALID_REQUEST-MISSING_OR_INVALID_R



我正在尝试通过PayPal API的文档上传证据文件(https://developer.paypal.com/docs/api/customer-disputes/v1/)

但我得到错误400-INVALID_REQUEST,MISSING_OR_INVALID_REQUEST_BODY。

我不明白我做错了什么。这是生成表单数据的代码的一部分:

const str = {
evidences: [
{
evidence_type: "PROOF_OF_FULFILLMENT",
evidence_info: {
tracking_info: [
{
carrier_name: "FEDEX",
tracking_number: "122533485"
}
]
},
notes: "Test"
}
]
}
const data = JSON.stringify(str);
const formData = new FormData();
formData.append('input', data);
formData.append('type', "application/json");
formData.append('file1', fileBuffer, {
filename: "@maor.pdf"
});

这是请求的日志:

{
method: 'post',
headers: {
'Content-Type': 'multipart/related; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW',
Authorization: 'Bearer XXXXXXXXXXX'
},
body: FormData {
_overheadLength: 364,
_valueLength: 75083,
_valuesToMeasure: [],
writable: false,
readable: true,
dataSize: 0,
maxDataSize: 2097152,
pauseStreams: true,
_released: false,
_streams: [
'----------------------------736530077015435126960318rn' +
'Content-Disposition: form-data; name="input"rn' +
'rn',
'{"evidences":[{"evidence_type":"PROOF_OF_FULFILLMENT","evidence_info":{"tracking_info":[{"carrier_name":"FEDEX","tracking_number":"122533485"}]},"notes":"Test"}]}',
[Function: bound ],
'----------------------------736530077015435126960318rn' +
'Content-Disposition: form-data; name="type"rn' +
'rn',
'application/json',
[Function: bound ],
'----------------------------736530077015435126960318rn' +
'Content-Disposition: form-data; name="file1"; filename="@maor.pdf"rn' +
'Content-Type: application/pdfrn' +
'rn',
<Buffer 25 50 44 46 30 20 6f 62 6a 0a 3c 3c 2f 50 61 67 65 0a 2f 50 61 72 65 6e 74 20 31 20 30 20 52 0a 2f 4d 65 64 69 ... 74855 more bytes>,
[Function: bound ]
],
_currentStream: null,
_insideLoop: false,
_pendingNext: false,
_boundary: '--------------------------736530077015435126960318'
}
}

我做错了什么?

我做错了什么?

您正在过帐表单数据。PayPal REST API不接受表单数据,只接受JSON字符串,对于此特定调用,该字符串必须是多类型内容字符串的一部分。请参阅链接到的文档,了解该字符串的外观;您并没有发布这样的字符串,从日志中可以清楚地看到。

相关内容

  • 没有找到相关文章

最新更新