API create file PUT gives Problems parsing JSON error

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:

var url = 'https://api.github.com/repos/xxx/yyy/contents/new5.js';

var headersObj = {
    "Content-Type": "application/vnd.github.v3+json",
    "Authorization": "token <valid token>"
};

var bodyObj = {
    "message": "commit message",
    "content": fileObjBase64
};

var apiResponse = https.put({
    url: url,
    headers: headersObj,
    body: bodyObj
});

This gives me “Problems parsing JSON” error too.
I need some help, how to set Body to raw or any other idea to create file.

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:

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.

In the above examples, the contents of fileObjBase64 are not visible. I believe that base64 encoded contents need some field specifying that it’s encoded data. Eg:

{
    "data": "JVBERi0xLjMNJeLjz9MNCjc ...

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.

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:

var bodyObj = JSON.stringify({
    "message": "commit message",
    "content": fileObjBase64
});