How to Show Field Names Instead of ID Values in HubSpot API Integration with Google Sheets

I’m pretty new to programming and working on connecting HubSpot to Google Data Studio through Google Apps Script and Sheets. When I pull deal data from HubSpot, I keep getting numeric IDs for things like deal stages and pipelines instead of their actual readable names. For example, instead of seeing “Proposal Sent” I get something like “12345678”. Other fields like deal names work fine and show the correct text.

function fetchContracts() {
  var authService = getAuthService();
  var requestHeaders = {headers: {'Authorization': 'Bearer '+ authService.getAccessToken()}};
  var continueLoop = true;
  var pageOffset = 0;
  var contractsList = Array();
  
  while(continueLoop) {
    var apiEndpoint = BASE_URL + "/deals/v1/deal/paged?properties=dealstage&properties=pipeline&properties=projectname&properties=value&properties=title&properties=category&limit=100&offset="+pageOffset;
    var apiResponse = UrlFetchApp.fetch(apiEndpoint, requestHeaders);
    var parsedData = JSON.parse(apiResponse.getContentText());
    continueLoop = parsedData.hasMore;
    pageOffset = parsedData.offset;
    
    parsedData.deals.forEach(function(contract) {
      var stageValue = (contract.properties.hasOwnProperty("dealstage")) ? contract.properties.dealstage.value : 0;
      var pipelineValue = (contract.properties.hasOwnProperty("pipeline")) ? contract.properties.pipeline.value : 0;
      var projectName = (contract.properties.hasOwnProperty("projectname")) ? contract.properties.projectname.value : "unknown";
      var contractValue = (contract.properties.hasOwnProperty("value")) ? contract.properties.value.value : 0;
      var contractTitle = (contract.properties.hasOwnProperty("title")) ? contract.properties.title.value : 0;
      var contractCategory = (contract.properties.hasOwnProperty("category")) ? contract.properties.category.value : 0;
      contractsList.push([stageValue,pipelineValue,projectName,contractValue,contractTitle,contractCategory]);
    });
  }
  return contractsList;
}

How can I modify this to get the display labels instead of these internal ID numbers?

Had this exact issue when I started with HubSpot’s API. Those properties return internal IDs by default, but you can get readable labels by tweaking your request parameters. Don’t just request property values - add includePropertyVersions=false and propertiesWithHistory=false for current values. Then hit the /properties/v1/deals/properties endpoint first to grab property definitions. I built a separate function that pulls all pipeline and deal stage options with their labels, dumps them in an object, then uses it as a lookup table when processing deals. One call for property metadata, then reference it for each deal record. Or just switch to the v3 deals API - it’s way better at returning formatted values directly. Different endpoint structure but handles this data transformation much cleaner than v1.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.