Posted Json To Google Apps Script, Need To Extract Value And Place In Google Sheets
I am posting a JSON to Google Apps Script and want to display a specific value from that JSON in Google Sheets. I use the following code to get the data into my sheet from this pos
Solution 1:
You can do something like the following:
functiondoPost(request) {
var ss = SpreadsheetApp.openById("ID here")
var sheet = ss.getSheetByName("Sheet1")
// Now Parse the body of your post request in to a data objectvar data = JSON.parse (request.postData.contents)
//Now put the data in the sheet
sheet.getRange(1, 1).setValue(data['myValue'])
// Note no need to stringify // now do your other stuff
The body of the post request is available to you in request .postData.contents
. Here's the Google documentation
You parse the content string into a JSON object and then access the fields you need.
Post a Comment for "Posted Json To Google Apps Script, Need To Extract Value And Place In Google Sheets"