Post method for uploading Attachment + JSON data without using FormData() in Airtable Scripting

Right now I am able to upload attachment (which is there in ‘data’ variable, without using FormData). using this code :

var filename = url.split('/')[url.split('/').length - 1];
        var data = await fetch(url).then(res => res.blob());
        console.log(data)
        var upload = await fetch("https://api.product.ai/v1/queues/139331/upload", {
          body : data,   
          headers: {
            Authorization: "token " + key,
            "Content-Disposition": "attachment; filename="+filename,
            "Content-Type": "application/x-www-form-urlencoded"
          },
          method: "POST"
        });
        console.log(upload);

Now I also want to upload JSON data along with the attachment using same Post method . This JSON data will contain cell values of different cloumns in airtable.

For this, the software has curl and JS code for uploading data. It uses form-data option for uploading attachment and other metadata(cell values of the airtable Table). Airtable doesn’t support form-data.

curl code :

curl -H 'Authorization: token db313f24f5738c8e04635e036ec8a45cdd6d6b03' \
  -F content=@document.pdf \
  -F values='{"upload:organization_unit":"Sales"}' \
  -F metadata='{"project":"Market ABC"}' \
  'https://api.product.ai/v1/queues/8236/upload'

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.