我正在使用 Google Apps 脚本来访问 Hubspot 联系人 API,并且一切正常:
var firstName = (item.properties.hasOwnProperty('firstname')) ? item.properties.firstname.value : "NA";
var lastName = (item.properties.hasOwnProperty('lastname')) ? item.properties.lastname.value : "NA";
var fullName = firstName + " " + lastName;
var companyName = (item.properties.hasOwnProperty('company')) ? item.properties.company.value : "NA";
...但我似乎无法查询与联系人地址相关的任何内容。
var streetAddress = (item.properties.hasOwnProperty('address')) ? item.properties.address.value : "NA";
var cityName = (item.properties.hasOwnProperty('city')) ? item.properties.city.value : "NA";
var stateName = (item.properties.hasOwnProperty('state')) ? item.properties.state.value : "NA";
var postalCode = (item.properties.hasOwnProperty('zip')) ? item.properties.zip.value : "NA";
streetAddress
, cityName
, stateName
,postalCode
似乎没有从我的 API 查询中返回任何内容。但是firstName
,,一切正常lastName
。companyName
我之前在检索电子邮件时遇到了一些麻烦,并在网上找到了解决方案。
任何想法为什么我的查找和分配 Hubspot 地址信息的代码不起作用?
这是我当前的 URL 查询(两个 URL 具有相同的效果,但顶部的 URL 较新,我认为如果我更具体地使用 API,我可以获得正确的属性):
var url_query = API_URL + "/contacts/v1/lists/all/contacts/all?properties=address&properties=firstname&properties=lastname&properties=company&properties=city&properties=state&properties=zip";
//var url_query = API_URL + "/contacts/v1/lists/all/contacts/all";
response.contacts.forEach(function(item) {
var vid = item.vid;
var firstName = (item.properties.hasOwnProperty('firstname')) ? item.properties.firstname.value : "NA";
var lastName = (item.properties.hasOwnProperty('lastname')) ? item.properties.lastname.value : "NA";
var fullName = firstName + " " + lastName;
var companyName = (item.properties.hasOwnProperty('company')) ? item.properties.company.value : "NA";
var streetAddress = (item.properties.hasOwnProperty('address')) ? item.properties.address.value : "NA";
var cityName = (item.properties.hasOwnProperty('city')) ? item.properties.city.value : "NA";
var stateName = (item.properties.hasOwnProperty('state')) ? item.properties.state.value : "NA";
var postalCode = (item.properties.hasOwnProperty('zip')) ? item.properties.zip.value : "NA";
Logger.log(fullName,streetAddress,cityName,stateName,postalCode);
var email = "NA";
// Not sure why, but a contact might have multiple identity-profiles, we take the firstone
item['identity-profiles'][0].identities.forEach(function(identity) {
if (identity.type == "EMAIL") {
email = identity.value;
}
});