亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從 Python 腳本向 Google App Script API 傳遞參數?

如何從 Python 腳本向 Google App Script API 傳遞參數?

皈依舞 2021-11-16 10:41:34
我有一個SalesID要傳遞給 Google App Script的論點。我怎樣才能通過這個 python 腳本傳遞它?(腳本來自https://developers.google.com/apps-script/api/how-tos/execute)from __future__ import print_functionfrom googleapiclient import errorsfrom googleapiclient.discovery import buildfrom httplib2 import Httpfrom oauth2client import file as oauth_file, client, toolsdef main(SalesID):    """Runs the sample.    """    SCRIPT_ID = '1WChnVrk5gycQEtumI7mPi5PexXafuhBAWN7-VnBK2aPkFpzMHtUp0cnx' #Actual Google Sheet Sample    # Setup the Apps Script API    SCOPES = ['https://www.googleapis.com/auth/script.projects','https://www.googleapis.com/auth/spreadsheets']    store = oauth_file.Storage('token.json')    creds = store.get()    if not creds or creds.invalid:        flow = client.flow_from_clientsecrets('credentials.json', SCOPES)        creds = tools.run_flow(flow, store)    service = build('script', 'v1', http=creds.authorize(Http()))    # Create an execution request object.    request = {"function": "getFoldersUnderRoot"}    try:        # Make the API request.        response = service.scripts().run(body=request,                scriptId=SCRIPT_ID).execute()        if 'error' in response:            # The API executed, but the script returned an error.            # Extract the first (and only) set of error details. The values of            # this object are the script's 'errorMessage' and 'errorType', and            # an list of stack trace elements.            error = response['error']['details'][0]            print("Script error message: {0}".format(error['errorMessage']))示例 Google 表格:https : //docs.google.com/spreadsheets/d/1Z4PAY3CCaRorn5LRdFQKn4-EcAHxwxHJsABzEgsSQk0/edit#gid=0基本上我希望能夠將 SalesID 從 shell 傳遞到 Google 應用程序腳本進行處理。謝謝!
查看完整描述

1 回答

?
千萬里不及你

TA貢獻1784條經驗 獲得超9個贊

正如官方文檔中所寫,您必須在請求正文中提供它:

request = {"function": "myFunction", "parameters": [{"salesID" : 123}]}

也用 setValue(e.salesID);

查看完整回答
反對 回復 2021-11-16
  • 1 回答
  • 0 關注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號