Deal API not working properly


I tried to use the Hubspot Deal API to export all deals from my existing deal data to google sheets, below is the code snippet where I call the API and display the data.

var url=“”;

var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());

for(var i=0; i <; ++i)
sheet.getRange(i + 2,1).setValue([i].properties.dealname.value);
sheet.getRange(i + 2,2).setValue([i].properties.dealstage.value);
sheet.getRange(i + 2,3).setValue([i].properties.hubspot_owner_id.value);
sheet.getRange(i + 2,4).setValue([i].properties.closedate.value);
sheet.getRange(i + 2,5).setValue([i].properties.jan_16.value);
sheet.getRange(i + 2,5).setValue([i].properties.associated_contacts.value);

While doing this, deals API does not return the amount, closedate and jan_16 fields. Along with this the dealstage and Hubspot owner gives back numbers while it should give back text. eg A deal with dealstage dead and Hubspot owner Claudia Summers featches e1198348-3542-4a80-8894-5d01a55b1a39 and 15230397 respectively. Kindly help


@Harshendra_Singh Are you using your own hapikey to authenticate? Above you have demo as your hapikey which means you are pulling the deals from our API demo portal and not your own.


Yes, he is using his own api key in the actual code. He posted it earlier and I suggested that he probably should remove it.


@Alexei_Vasilkov and @Harshendra_Singh Can you expand upon where you are getting this number from?(e1198348-3542-4a80-8894-5d01a55b1a39) That doesn’t look like anything that should be associated with a dealstage property. As for the HubSpot Owner. You are getting the Hubspot Owner ID. It is supposed to return a number. You can cross reference the owners API to get a name in English. Is the API not returning the amount for the deals that actually have an amount filled out already? If the amount or closedate is blank then the API wouldn’t return it.


Hi @pmanca,
Thank you for such a quick reply.
e1198348-3542-4a80-8894-5d01a55b1a39 is the number i get in response to fetching the deal stage which is “dead” for this instance


@Harshendra_Singh can you PM me your portal ID so I can look into it further. That is an odd type of number to receive for a value of a dealstage


@Harshendra_Singh I can reproduce your issue. I have noticed that it says you imported all of these deals. When you imported them, did you assign a deal stage to them properly? Maybe this a default value that got assigned to it due to the way the deals were imported? When I make a deal in the UI and then grab it via the API I get a proper response. Below is what I get:

      "value": "decisionmakerboughtin",
      "timestamp": 1481116495755,
      "source": "CRM_UI",
      "sourceId": "",
      "versions": [
          "name": "dealstage",
          "value": "decisionmakerboughtin",
          "timestamp": 1481116495755,
          "sourceId": "",
          "source": "CRM_UI",
          "sourceVid": []

I would double check the way the deals were imported.


Could you kindly share the API URL, code and method you followed to do this.

Also, what should be our method of importing to not get the numbers in response to api call


@Harshendra_Singh As you can see in the JSON I made the deal in the UI. The API call was the same one as you made the only difference was that I made a deal in the UI and you imported your deals. Here is some documentation on importing deals to help you.