API create file PUT gives Problems parsing JSON error #21447
-
I try to create file from a Netsuite (more or less javascript) script file. When I try to create a file I get “Problems parsing JSON” error message. I tried it from Postman and it gives me the same error when tring to set Body as “form-data” but it was success when set Body as “Raw”. (on one picture because new user can upload only one…) Code:
This gives me “Problems parsing JSON” error too. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
NetsuiteVS:
This might be related to the raw data being passed in base64 encoding, and the need to escape the encoded string in one context. See:
How to format Base64 encoded string while sending in JSON
javascript, java, groovy, base64
asked by
learn groovy
on 08:25PM - 03 Aug 18 UTC
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. As you can see on the picture the base64 text doesn’t contains any special character except one =. Althrough I tried to remove ‘=’ char and I still get the same error. |
Beta Was this translation helpful? Give feedback.
-
In the above examples, the contents of
or something like that. In DataURIs you also have to add some prefix to let the parser know it’s encoded data. There must be something missing there which doesn’t allow the JSON parser to realize that some base64 data is coming — the whole purpose of Base64 encoding is, after all, to convert binary data (which might contain invalid bytes for a string) into a parseable string of ASCII chars. |
Beta Was this translation helpful? Give feedback.
-
You can see the base64 content on the picture. In the content parameter’s value.
|
Beta Was this translation helpful? Give feedback.
You can see the base64 content on the picture. In the content parameter’s value.
Meanwhile I found the solution. Netsuite transformed the body json in the background from
“message”: “some message”
to
message": {“some message”} .
Solution is giving json as string format: