My application is issuing the following error:
Failed: Webhook HTTP post request failed with exception The remote server returned an error: (401) Unauthorized.
I created the script on Google Sheet, published it to the web and created an apikey key.
however it emits the error.
Need a little more details on your setup (how you published the web app, what kind of api key etc)
Please contact support@appsheet.com for help with this.
Hi,
see the information:
_
Google Sheet - Macro Script
_
Google Cloud Platform
_
AppSheet
check this link, I put all the images of the procedure performed, because I couldn’t add them here in the post
_
URL:
https://script.google.com/macros/s/<key_script>/exec?apikey=<API_KEY_generated>
the correct url is this, with the ?apikey= parameter, or I must change it to ?key=
_
TKS
The user has no access to your sheet so they can’t run your web app as the user. Have you added read access to your gsheet for each user?
@Rodrigo_Brancaglion
I couldn’t be able to understand why do you need to generate an API key? You just need to enclose your script function with a doPost(e) as you have already published your code as a webapp. Have you published the webapp with an accessibility option of anyone even anonymous?
@Rodrigo_Brancaglion
The video that you are referring to is completely a different thing. The script approach demonstrated on the video is using Directory API and that API needs a key for access. That’s the reason he’s passing an API key as a URL parameter.
May I ask what’s your script is doing? What’s the purpose of it and how do you want to use that script?
My script is very simple.
After the AppSheet inserts the data in the spreadsheet, the script should take the cell phone of the “ID CLIENT” look for this id in the Client tab and insert the name of this client in the cell corresponding to the Name.
The script works correctly if you run it individually.
However, I have already done the tests without the ‘apiKey’ parameter in the URL.
The error that returned is the same - 401
image: 0 - erroSend.png in GoogleDrive
TKS
You don’t need to use a script for that actually. There are 2-3 different ways to accomplish the same result with using actions, DataChange Workflow or preset AppSheet API Edit Row mechanisms. Provided you insistingly want to use scripting, then you don’t need to use the webapp, but onChange(e) trigger instead. Check this post:
sorry i can´t see all the deatils and maybe this answer could be useless but i think that the problem may prove to be the access permits on the script when you deployed it, maybe if you execute the script as yourself and give permits to all then the script will function.
User | Count |
---|---|
17 | |
11 | |
7 | |
5 | |
5 |