【发布时间】:2020-10-25 07:28:37
【问题描述】:
我可以通过 Google Apps 脚本创建联系人,并添加电话号码,但我无法添加地址,收到错误消息“找不到您请求的资源。”
注意:fName、actualLastName、email、address & phone1 都是字符串
// create the Contact
var newContact = ContactsApp.createContact(fName, actualLastName, email);
var newName = newContact.getFullName();
Logger.log("newName: " + newName);
Logger.log("New contact added");
// attempt to add the address - DOESN'T WORK
try {
Logger.log("Wanting to add this address: ", address);
newContact.addAddress(ContactsApp.Field.WORK_ADDRESS, address);
Logger.log("Address added");
} catch(err) {
Logger.log("Stumbled while trying to add address: " + err.message);
Browser.msgBox("Stumbled while trying to add address to contact");
}
记录的错误消息是:“尝试添加地址时出现信息错误:找不到您请求的资源。”
添加电话号码可以正常工作:
newContact.addPhone(ContactsApp.Field.MOBILE_PHONE, phone1);
联系人被添加到相应的组中:
var group = ContactsApp.getContactGroup("System Group: My Contacts");
group.addContact(newContact);
【问题讨论】:
-
虽然我不确定这是否是您问题的直接解决方法,例如,该线程中的评论方法对您的情况有用吗? stackoverflow.com/q/64200243/7108653
-
感谢您的回复。我很高兴你的问题得到了解决。我认为这可能对其他用户也有用。我将其发布为答案。你能确认一下吗?不幸的是,我没有在问题跟踪器上检查过这种情况。如果您在问题跟踪器中找不到此问题,我建议您报告它。
-
确实如此。我已在您的回答中添加了评论。
-
嗨,我无法重现这种行为。使用您的原始代码时,我没有收到任何错误。你还在经历这种情况吗?
-
@lamblichus 奇怪的是,它现在似乎对我有用 ID 调用。我会进一步检查。
标签: google-apps-script google-contacts-api