Help

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

Topic Labels: API
2476 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Ankit_Srivasta1
4 - Data Explorer
4 - Data Explorer

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'
0 Replies 0