Postman上具有base64字符串的无效JSON数据

时间:2018-12-12 11:45:27

标签: javascript json base64 postman

我需要使用Postman发送一些JSON请求。我在这里遇到base64 string的问题。如何正确格式化为JSON属性?希望我做错了。

注意:base64字符串的长度更长。我已经提取了一部分。

{
"api_key": "m40q-412u-99bd-388d-yazn",
 "file_name": "fileName.pdf",
 "file_content": "data:image/*;charset=utf-8;base64,JVBERi0xLjQKJe+/ve+/ve+/ve+/vQoxIDAgb2JqCjw8CiAgL1R5cGUgL0NhdGFsb2cKICAvUGFn
ZXMgMiAwIFIKPj4KZW5kb2JqCgoyIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2VzCiAgL01lZGlhQm94
IFsgMCAwIDI0ODAgMzUwOCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2Jq
CgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL01lZGlhQm94IFsg
MCAwIDU5MyA4NDEgXQogIC9SZXNvdXJjZXMgPDwKICAgIC9Gb250IDw8CiAgICAgIC9GMSA0IDAg
UgogICAgPj4KICAgIC9YT2JqZWN0IDw8CiAgICAgIC9pbWcxIDYgMCBSCiAgICA+PgogID4+CiAg
L0NvbnRlbnRzIDUgMCBSCj4+CmVuZG9iagoKNCAwIG9iago8PAogIC9UeXBlIC9Gb250CiAgL1N1
YnR5cGUgL1R5cGUxCiAgL0Jhc2VGb250IC9UaW1lcy1Sb21hbgogIC9FbmNvZGluZyAvV2luQW5z
aUVuY29kaW5nCj4+CmVuZG9iagoKNSAwIG9iago8PAogIC9MZW5ndGggNjIKPj4Kc3RyZWFtCnEK
MSAwIDAgMSAwIDAgY20KMSAwIDAgMSAwIDAgY20KNTkyIDAgMCA4NDEgMCAwIGNtCi9pbWcxIERv
ClEKZW5kc3RyZWFtCmVuZG9iagoKNiAwIG9iago8PAogIC9MZW5ndGggMzQ3NDUKIC9UeXBlIC9Y
T2JqZWN0CiAvU3VidHlwZSAvSW1hZ2UKIC9GaWx0ZXIgL0RDVERlY29kZQogL1dpZHRoIDQyMwog"
}

我的API显示此错误:

{
    "errors": [
        {
            "code": 400,
            "detail": "Invalid JSON data."
        }
    ]
}

1 个答案:

答案 0 :(得分:1)

问题似乎出在换行符(回车)上,只需复制此json并将其粘贴到jsonlint.com中即可。

您可以进一步参考该问题以获取更多详细信息,Multiline strings in JSON