Multipart

Request of multipart/form-data with Simple Request Body using Google Apps Script

Gists

This is a sample script of the request of multipart/form-data with a simple request body using Google Apps Script. I hope that the users will easy to use Class UrlFetchApp by this report.

This report is the updated post of “Multipart-POST Request Using Google Apps Script”.

Description

I had already reported about this at this report. In that case, it was required to create a bit complicated request body to request multipart/form-data. Today, by a comment, I could notice the sample script of Class UrlFetchApp in the official document had been updated. By this, I thought that multipart/form-data will be requested with a simple request body. In this report, I would like to introduce a sample script for requesting multipart/form-data with a simple request body. But I’m not sure whether this request got to be able to be done by the internal update of Class UrlFetchApp.

Multipart-POST Request Using Google Apps Script

Gist

These sample scripts are for requesting multipart post using Google Apps Script.

In most cases, the multipart request is used for uploading files. So I prepared 2 sample situations as follows. For each situation, the request parameters are different.

  1. Upload a file from Google Drive to Slack.
  2. Convert an excel file to Spreadsheet on Google Drive using Drive API v3.

Multipart post is required for these situations.

1. Uploading Files From Google Drive To Slack

Curl Code

In order to use this sample, please retrieve access token for uploading file to Slack.