How to upload file via javascript request


Hi, I've read through the API for uploading to filemanager using Python, I'm now trying to use the API to upload a PDF to the filemanager via netsuite using their Javascript API.

I the netsuite API sends a post request but only uses 3 parameters : API Url, headers and Body

I have the API url and set to the endpoint with the hAPIkey generated :

For the body i set it to the multipart/form-data and the multi-part form encoded PDF.
However we dont have a data parameter so im not sure where to set the data and the folder paths :

        "folder_paths": "folder-in-the-cos-file-manager/subfolder"

when I try to send out the post request it just returns an response code 406 with no message

   type: "http.ClientResponse",
   code: 406,
   headers: {
      "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
      Server: "cloudflare",
      "CF-RAY": "49aff0f6b937a6dd-DUB",
      "Access-Control-Allow-Credentials": "false",
      "Set-Cookie": "__cfduid=d6c3edc2ea00fe02ce37cc28a07eaac071547802760; expires=Sat, 18-Jan-20 09:12:40 GMT; path=/;; HttpOnly",
      "Content-Length": "0",
      Date: "Fri, 18 Jan 2019 09:12:40 GMT",
      "Expect-CT": "max-age=604800, report-uri=""",
      Via: "1.1"
   body: ""

any assistance is appreciated on how to proceed with a successful upload



Hi @wesley.lim11, that error looks like it's coming from Cloudflare so I can't be certain what it means. That said, have you tried using code snippets in Postman: I'd try making a simple request with a form upload field by changing the value of the form field to a type of file:

Then having the Code snippet get generated for you based off of the successful request.