doPost Not working

1,033 views
Skip to first unread message

Arpan Roy

unread,
Jan 18, 2022, 3:33:40 PM1/18/22
to Google Apps Script Community
function doPost(e) {

  var json = JSON.parse(e.postData.contents);
  Logger.log("Request Received"); 
  Logger.log(json); 
  return ContentService.createTextOutput(JSON.stringify(json));
}

I have made a post request through postman but nothing happened there and got "401 Unauthorized" response in postman.

Could you please guide me how can I solve this issue?

Actually I want to get shopify order data through this app script webhook. That's why I was testing it through postman first but it wasn't working

Tanaike

unread,
Jan 18, 2022, 9:00:18 PM1/18/22
to Google Apps Script Community
Can you provide the current setting of your Web Apps? For example, the values of "Execute as:" and "Who has access to the app:".

Arpan Roy

unread,
Mar 20, 2022, 6:36:17 AM3/20/22
to Google Apps Script Community
I have changed the code to
const doPost = (request) => {
  console.log(request);
  return ContentService.crateTextOutput(JSON.stringify(request));
};

Deploy as webapp
Execute as: Me
Access anyone with google account.

I have made post request using POSTMAN but nothing happened in executions.

Can you please guide me / send me the correct code to capture the post request?

Tanaike

unread,
Mar 20, 2022, 9:58:35 PM3/20/22
to Google Apps Script Community
Thank you for replying. From your reply, in your setting of Web Apps, I understood as follows.

  • "Execute as:" is "Me"
  • "Who has access to the app:" is "Access anyone with google account"

In this case, I think that the access token is required to be used for access to the Web Apps. For this, is this information useful? Ref

Heber Chavez

unread,
Dec 27, 2022, 3:47:49 PM12/27/22
to Google Apps Script Community
Esto puede pasar si no es propietario y tratas de ejecutar scritp
Reply all
Reply to author
Forward
0 new messages