How can I POST a value to google sheets using Google App Script?

You are using GAS (Google Apps Scrip) which has to ways to write to the sheet

  • doGet()
  • doPost()

When using doGet(), you have to pass the parameters as part of the URL (Query Parameters) and therefore you need to convert them to a form accepted by the URL scheme. This is the reason why you have to change the text to URLEncoded text.

However, when you use doPost() you will pass the data using the Body block and therefore you can use all type of text and numbers.

You can pass a JSON formatted data in text form using the Body component and in the Google script side read the text and convert it using JSON.parse() to use it as an object and update the sheet.

See a post using doPost().

1 Like