APIs & Integrations

KB496
参加者 | Solutions Partner
参加者 | Solutions Partner

Unexpected API response

解決

Hi Team,

 

My goal here is to retrieve the values Deal Name, Amount, Closed Date ,Stage , Pipeline for a specific Deal. Im using get a deal endpoint to do so.

However get a Deal API Output shows encoded or indexed value.

Expected Output = G Suite
The Output  that I got =  1129c87a-a92b-472d-a9bb-604692e5d2ea
 
Below are the screenshots that can be used to understand the issue.  
 
jsonDatafromGetDealApi.pnghbScreenshot.png
 
Any help is appreciated.
Regards,
Komal
0 いいね!
1件の承認済みベストアンサー
jackcoldrick
解決策
HubSpot Employee
HubSpot Employee

Unexpected API response

解決

Hi @KB496,

 

HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. Using any of the HubSpot endpoints to extract information relating to dates will return milliseconds. There is more information on this here.

 

To clarify further, if I have a deal with a "Closed Date" = 09/01/2020 I would make a GET request using the "Get a deal" endpoint. The response body would contain the following, the bold text is the millisecond timestamp representing the date 09/01/2020.

 

"closedate": {
            "value": "1578584645680",
            "timestamp": 1578584647878,
            "source": "CRM_UI",
            "sourceId": "jackcoldrick@hubspot.com",
            "versions": [
                {
                    "name": "closedate",
                    "value": "1578584645680",
                    "timestamp": 1578584647878,
                    "sourceId": "jackcoldrick@hubspot.com",
                    "source": "CRM_UI",
                    "sourceVid": []
                }
            ]
        }

 

I could then use the "value" and convert into the appropriate date format. There are many different ways to convert UNIX millisecond timestamps to readable dates. One example would be using Javascript:

 

var milliseconds = 1578584645680;
var readableDate = new Date(milliseconds);
console.log(readableDate)

The output of the above would be "Thu Jan 09 2020 15:44:05 GMT+0000 (Greenwich Mean Time)".

 

Regards,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn

元の投稿で解決策を見る

3件の返信
jackcoldrick
HubSpot Employee
HubSpot Employee

Unexpected API response

解決

Hi @KB496,

 

This is expected behaviour. What is being returned to you is the internal ID of the deal pipeline. You can use the ID returned to pull the pipeline name using the "Get Deal Pipeline" endpoint.

 

I hope this helps,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
KB496
参加者 | Solutions Partner
参加者 | Solutions Partner

Unexpected API response

解決

Hi Jack,

 

Thankyou for responding.

I would also want to bring to your notice that while I extract "Closed date" the output returned for this is an alphanumeric string however the expected value here is "dd-mm-yyyy". 

 

Can you please look into this and revert back at earliest.

 

Thanks,

Komal

 

0 いいね!
jackcoldrick
解決策
HubSpot Employee
HubSpot Employee

Unexpected API response

解決

Hi @KB496,

 

HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. Using any of the HubSpot endpoints to extract information relating to dates will return milliseconds. There is more information on this here.

 

To clarify further, if I have a deal with a "Closed Date" = 09/01/2020 I would make a GET request using the "Get a deal" endpoint. The response body would contain the following, the bold text is the millisecond timestamp representing the date 09/01/2020.

 

"closedate": {
            "value": "1578584645680",
            "timestamp": 1578584647878,
            "source": "CRM_UI",
            "sourceId": "jackcoldrick@hubspot.com",
            "versions": [
                {
                    "name": "closedate",
                    "value": "1578584645680",
                    "timestamp": 1578584647878,
                    "sourceId": "jackcoldrick@hubspot.com",
                    "source": "CRM_UI",
                    "sourceVid": []
                }
            ]
        }

 

I could then use the "value" and convert into the appropriate date format. There are many different ways to convert UNIX millisecond timestamps to readable dates. One example would be using Javascript:

 

var milliseconds = 1578584645680;
var readableDate = new Date(milliseconds);
console.log(readableDate)

The output of the above would be "Thu Jan 09 2020 15:44:05 GMT+0000 (Greenwich Mean Time)".

 

Regards,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn