简体   繁体   中英

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

I am trying to get the property values of the Deal Object in Hubspot. I am able to see them via Postman. However, when I try to make the same call via Node.js it doesn't give me the property values.

This is the API 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

With Postman, I am able to get the dealname, dealstage and the rest of the properties that are specified in the 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": { "associatedVid s": [], "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": "d ealname", "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": [] } ] }, "n um_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": "CAL CULATED", "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", "ti mestamp": 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", "valu e": "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": [] } ] } }, "imp orts": [], "stateChanges": [] } ], "hasMore": true, "offset": 22908009 }

Whereas with Node.js, I am not able to get the property values Here is the output from 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: fal se, 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 }

As you might observe with the property key, it shows [object] as it's value, when it should actually specify the values of the properties.

Here is the Node.js code that I had written-

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);

  })

Here is a reference to the Deals API Documentation in Hubspot: https://developers.hubspot.com/docs/methods/deals/get-all-deals

The data is all there. It's showing [Object] because you're doing a console.log , which doesn't output EVERYTHING. Try this instead:

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

That will show you EVERYTHING (and the 2 makes it space out well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM