APIs & Integrations

kcraft
Teilnehmer/-in

Inconsistent results from Search API

When I query the api for all deals that have values in the custom field "square order ID," I'm receiving inconsistent results. Occassionally I will get the correct list, however more often I receive a list with the same amount of total results, but it contains a couple duplicates and is missing some records. I have run it multiple times in a row without changing any code and am seeing this result.

0 Upvotes
4 Antworten
WendyGoh
HubSpot Employee
HubSpot Employee

Inconsistent results from Search API

Hey @kcraft,

 

In order for me to further troubleshoot this, could you share with me the following:

 

1. Portal ID in question

2. The exact request URL that you're calling

3. The POST body (if any)

0 Upvotes
kcraft
Teilnehmer/-in

Inconsistent results from Search API

1. 6430533

2. var url = "https://api.hubapi.com/crm/v3/objects/deals/search?";

3. below

 

var body = {
"limit": 60,
"after": after,
"properties": ["square_order_id","dealname","memo","dealtype","closedate","amount","discount","tax","service","fee","refund","season","dealstage"],


"filterGroups":[
{
"filters":[
{
"propertyName": "square_order_id",
"operator": "HAS_PROPERTY"
}


]
}
]
}

var options = {
"method" : "POST",
"payload" : JSON.stringify(body),
"headers" : {"Content-Type": "application/json",
'Authorization': 'Bearer ' + service.getAccessToken()},
"muteHttpExceptions": true
};


with paging done with this:

var after = (result.hasOwnProperty("paging")) ? result.paging.next.after : null;

 

I can provide the JSON responses with the duplicates as well but those are obviously large blocks of text.


0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Inconsistent results from Search API

Hey @kcraft,

 

On my end, I'm not seeing any duplicates. 

 

Could you share with me the deal IDs that are duplicates? Do you mean that you're seeing i.e. deal ID 123 on after 60 and is seeing deal ID 123 on after 120? If so, could you also share with me the after parameter used?

0 Upvotes
kcraft
Teilnehmer/-in

Inconsistent results from Search API

Yes, sometimes I don't see duplicates but most times I do. I just ran it and found IDs 1700753718, 1700697531, and 1700680518 in both the first response and the "after 60" response. Also deals 1700680522, 1700753719, and 1700753721 are not included in the response despite falling under the criteria.

 

 

var after = (result.hasOwnProperty("paging")) ? result.paging.next.after : null;

 

I tried again with a 40 response limit and got a duplicate of 1700753712. In the 60 example the duplicates were the 57th, 58th, and 59th deals in the first response as well as the first, second, and third deals in the second response. In the 40 example the dupe was the 39th deal in the first response and the first deal in the second response.

0 Upvotes