我正在尝试通过de Google Scipt编辑器在PandaDoc中创建一个新文档。
一切正常(文档是使用正确的名称和模板创建的),但收件人不会通过。如果我与Postman发布相同的参数,收件人确实会通过。它可能与收件人参数的格式有关,但我没有足够的经验看什么。
这是我的代码:
function createPandaDoc() {
var formData = {
"name": "Sample Document5",
"template_uuid": "BDZRbdUt7abCbYFBBBREaL",
"recipients": [
{
"email": "john@appleseed.com",
"first_name": "John",
"last_name": "Appleseed",
"role": "Signer"
}
]
};
// Because payload is a JavaScript object, it will be interpreted as
// as form data. (No need to specify contentType; it will automatically
// default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
var options = {
'method' : 'post',
'headers' : {
Authorization : 'Bearer xxx',
contentType : 'application/json'
},
'payload' : formData
};
UrlFetchApp.fetch('https://api.pandadoc.com/public/v1/documents', options);
}
如果您有任何想法,请告诉我们!
谢谢Chris
答案 0 :(得分:0)
知道了!应该是:
function createPandaDoc() {
var formData = {
'name': 'Sample Document5',
'template_uuid': 'BDZRbdUt7abCbYFBBBREaL',
'recipients': [
{
'email': 'john@appleseed.com',
'first_name': 'John',
'last_name': 'Appleseed',
'role': 'Signer'
}
]
};
// Because payload is a JavaScript object, it will be interpreted as
// as form data. (No need to specify contentType; it will automatically
// default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
var options = {
'method' : 'post',
'contentType' : 'application/json',
'headers' : {
Authorization : 'Bearer xxxx'
},
'payload' : JSON.stringify(formData)
}
UrlFetchApp.fetch('https://api.pandadoc.com/public/v1/documents', options);
}