无法使用 API 获取 Hubspot 中对象的 属性 值

Not able to get property values of an object in Hubspot using the API

我正在尝试获取 Hubspot 中交易对象的 属性 值。我可以通过 Postman 看到它们。但是,当我尝试通过 Node.js 进行相同的调用时,它不会给我 属性 值。

这是APIURL:https://api.hubapi.com/deals/v1/deal/paged?hapikey=demo&includeAssociations=true&properties=dealname&properties=dealstage&properties=closedate&properties=hubspot_owner_id&properties=amount&limit=10

使用 Postman,我可以获得交易名称、交易阶段和 URL

中指定的其余属性

{ "deals": [ { "portalId": 62515, "dealId": 22900219, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "MadKudu", "timestamp": 1525078747520, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "MadKudu", "timestamp": 1525078747520, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461237738053, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461237738053, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22901709, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461241957842, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461241957842, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461241957842, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461241957842, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22902634, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461244142358, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461244142358, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461244142358, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461244142358, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22905614, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461248390906, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461248390906, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461248390906, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461248390906, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22905684, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461248467787, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461248467787, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461248467787, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461248467787, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22906614, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "kola11-national", "timestamp": 1461249908869, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "kola11-national", "timestamp": 1461249908869, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461249908869, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461249908869, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22907409, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "alok111-national", "timestamp": 1461250718805, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "alok111-national", "timestamp": 1461250718805, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461250718805, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461250718805, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22907704, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "kola54321-national", "timestamp": 1461250972802, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "kola54321-national", "timestamp": 1461250972802, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461250972802, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461250972802, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22907709, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461250988473, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461250988473, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461250988473, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461250988473, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] }, { "portalId": 62515, "dealId": 22908009, "isDeleted": false, "associations": { "associatedVids": [], "associatedCompanyIds": [], "associatedDealIds": [] }, "properties": { "dealname": { "value": "$username", "timestamp": 1461251673754, "source": "API", "sourceId": null, "versions": [ { "name": "dealname", "value": "$username", "timestamp": 1461251673754, "source": "API", "sourceVid": [] } ] }, "num_associated_contacts": { "value": "0", "timestamp": 0, "source": "CALCULATED", "sourceId": null, "versions": [ { "name": "num_associated_contacts", "value": "0", "source": "CALCULATED", "sourceVid": [] } ] }, "dealstage": { "value": "appointmentscheduled", "timestamp": 1461251673754, "source": "API", "sourceId": null, "versions": [ { "name": "dealstage", "value": "appointmentscheduled", "timestamp": 1461251673754, "source": "API", "sourceVid": [] } ] } }, "imports": [], "stateChanges": [] } ], "hasMore": true, "offset": 22908009 }

而使用 Node.js,我无法获得 属性 值这是 Node.js

的输出

{ deals: [ { portalId: 62515, dealId: 22900219, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22901709, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22902634, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22905614, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22905684, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22906614, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22907409, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22907704, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22907709, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] }, { portalId: 62515, dealId: 22908009, isDeleted: false, associations: [Object], properties: [Object], imports: [], stateChanges: [] } ], hasMore: true, offset: 22908009 }

正如您使用 属性 键观察到的那样,它显示 [object] 作为它的值,而实际上它应该指定属性的值。

这是我写的Node.js代码-

var fetch = require("node-fetch");
const url='https://api.hubapi.com/deals/v1/deal/paged?hapikey=demo&includeAssociations=true&properties=dealname&properties=dealstage&properties=closedate&properties=hubspot_owner_id&properties=amount&limit=10';

fetch(url)
.then((resp) => resp.json()) // Transform the data into json
.then(function(data) {
    console.log(data);

  })

这是对 Hubspot 中交易 API 文档的引用:https://developers.hubspot.com/docs/methods/deals/get-all-deals

数据都在那里。它显示 [Object] 是因为您正在执行 console.log,它不会输出所有内容。试试这个:

console.log(JSON.stringify(data, null, 2));

这会告诉你一切(2 使它 space 很好)。