1

I need to use Postman to send some JSON request. I have an issue here with base64 string. How can I format correctly as JSON property? Hope I have done wrong there.

Note: base64 string has more length. I have extracted part of it.

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

My API shows this error:

{
    "errors": [
        {
            "code": 400,
            "detail": "Invalid JSON data."
        }
    ]
}
Sampath
  • 63,341
  • 64
  • 307
  • 441

1 Answers1

1

The problem seems to be with the new line (carriage return), just copy this json and paste it in jsonlint.com you will get to know.

You can further refer this question for more details Multiline strings in JSON

smali
  • 4,687
  • 7
  • 38
  • 60
  • How to fix that issue? Any tool? This is a very long string. – Sampath Dec 12 '18 at 12:02
  • just past it in jsonviewer.com and click on remove white space or format, if you want to use multiline use the above-provided solution in the linked question. – smali Dec 12 '18 at 12:05