微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

找不到脚本函数:doGet

如何解决找不到脚本函数:doGet

这些是我正在运行的示例代码
“script_url”是部署的谷歌脚本网络应用程序和生成的网址

sample.py

import requests
import datetime

url = "script_url?client_name={}&client_address={}&company_name={}&company_address={}&vessel_name={}&po={}&id={}&date={}&item1={}&item2={}&item3={}&cost1={}&cost2={}&cost3={}&total={}"

name_client = ["inder","sawpnesh","kajal"]
address_client = ["addinder","addswapnesh","addkajal"]
name_company = ["ospl","ospl","ospl"]
address_company = ["addospl","addospl","addospl"]
vessel_name = ["redlips","elizabth","jack"]
po = ["EWDCC","wefwec","asxwq"]
invoice_ids = ["1","2","3"]
item1 = ["keyboard","mouse","screen"]
item2 = ["mouse","screen","keyboard"]
item3 = ["screen","keyboard","mouse"]
cost1 = ["1000","500","2000"]
cost2 = ["500","2000","1000"]
cost3 = ["2000","1000","500"]

i = 0
for invoice_id in invoice_ids:
    total = cost3[i] + cost2[i] + cost1[i]
    print("processing ",invoice_id)
    response = requests.get(
        url.format(name_client[i],address_client[i],name_company[i],address_company[i],vessel_name[i],po[i],invoice_id,datetime.date.today(),item1[i],item2[i],item3[i],cost1[i],cost2[i],cost3[i],total
                   ))
    # response = requests.get(
    #     url.format(invoice_id,cust_names[i],add_streets[i],add_citys[i],issue_dates[i],last_dates[i]))
    print("file generated")
    response = requests.get(response.content)
    print("file downloaded")
    i += 1
    with open("invoice{}.pdf".format(invoice_id),"wb") as f:
        f.write(response.content)
    # i += 1

这是我正在运行的谷歌脚本应用程序 代码.cs

function createDocument(id,client_name,client_address,company_name,company_address,vessel_name,po,date,item1,item2,item3,cost1,cost2,cost3,total) {
  var TEMPLATE_ID = 'template_id';  
  var documentId = DriveApp.getFileById(TEMPLATE_ID).makecopy().getId();
  
  drivedoc = DriveApp.getFileById(documentId);
  drivedoc.setName("Invoice " + id+"/2021");
  
  doc = DocumentApp.openById(documentId);
  
  var body = doc.getBody();
  
  body.replaceText('{id}',id);
  body.replaceText('{client_name}',client_name);
  body.replaceText('{client_address}',client_address);
  body.replaceText('{company_name}',company_name);
  body.replaceText('{company_address}',company_address);
  body.replaceText('{vessel_name}',vessel_name);
  body.replaceText('{po}',po);
  body.replaceText('{date}',date);
  body.replaceText('{item1}',item1);
  body.replaceText('{item2}',item2);
  body.replaceText('{item3}',item3);
  body.replaceText('{cost1}',cost1);
  body.replaceText('{cost2}',cost2);
  body.replaceText('{cost3}',cost3);
  body.replaceText('{total}',total);
  
  drivedoc.setSharing(DriveApp.Access.ANYONE_WITH_LINK,DriveApp.Permission.EDIT);

  return "https://docs.google.com/document/d/" + documentId + "/export?format=pdf";
}
function doGet(e) {
  var id = e.parameter.id;
  var client_name = e.parameter.client_name;
  var client_address = e.parameter.client_address;
  var company_address = e.parameter.company_address;
  var company_name = e.parameter.company_name;
  var vessel_name = e.parameter.vessel_name;
  var po = e.parameter.po;
  var date = e.parameter.date;
  var item1 = e.parameter.item1;
  var item2 = e.parameter.item2;
  var item3 = e.parameter.item3;
  var cost1 = e.parameter.cost1;
  var cost2 = e.parameter.cost2;
  var cost3 = e.parameter.cost3;
  var total = e.parameter.total;

  var url = createDocument(id,total);
  return ContentService.createtextoutput(url);
}

当我执行 url 时 script_url?client_name=inder&client_address=addinder&company_name=ospl&company_address=ospladd&vessel_name=SEAQUEEN&po=324231&id=1&date=12/1/21&item1=keyboard&item2=mouse&item3=&cost1=1000&cost2=500&cost3=&total=1500

它给了我以下错误

enter image description here

我无法使用此脚本使用谷歌脚本将数据输入到我的谷歌文档模板中,模板 ID 为 TEMPLATE_ID。我的 python 代码运行良好。请帮我解决这个问题

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?