Uploading file to Netsuite using Postman
I’m trying to upload file to Netsuite through the postman. I’m using form-data to upload file but when i hit the post method I’m getting error 500.
Not sure of the right way to do this, but in the past we have used a custom restlet that accepted a JSON document with the file data being base64 encoded into one of the JSON properties.
i.e.
the client would send something like this:
{
“fileName”:”myfile.txt”,
“fileData”:”aGVsbG8gd29ybGQ=” /* hello world */
}
and then we would have a restlet to decode the base64 “fileData” property and store it into a file. Something like the following:
define(["N/file", "N/encode"], function (file, encode) {function post(requestData) {const fileId = file.create({name: requestData.fileName,encoding: file.Encoding.UTF_8,contents: encode.convert({inputEncoding: encode.Encoding.BASE_64,outputEncoding: encode.Encoding.UTF_8,string: requestData.fileData,}),fileType: file.Type.PLAINTEXT,folder: 12 /* replace with your folder to store into */,})return {"fileId": fileId}}return {post: post,}})



