Smartling/api-scripts

Can not upload file using V2 API

Opened this issue · 0 comments

Keep getting 500

500 - An error has occurred and administrators have been notified. For more information, please contact * with reference code "soidfdix"

when post file to upload:

    const config = {
        headers: {
          "Authorization": `Bearer ${TOKEN}`,
          "Content-Type": "multipart/form-data" //application/json
        }
    }

    const payload = {
      "file": fs.readFileSync(filePath),
      "fileUri": FILE_URI,
      "fileType": "json"
    }

    axios.post(SMARTLING_URL, payload, config)
    .then(res => {
      return res;
    })
    .catch(e => {
      return e
    })

Also tried FormData and pipe fs.readFile, but none of them are working. Could you please provide a clearer example of how to POST to your API?

BTW, I'm also considering creating a node-smartling package to help the others so they can easily use V2 API without the hard work.