Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to download data from hubspot
loop is not getting all only first set
every time i need to pass output value to URL using this variable (vRowCount)
i test with postman
As I posted earlier: Before entering the loop, you have to initiate the variable:
SET vMore = 'True';
In your case:
SET vMore = 'True';
DO WHILE vMore = 'True';
// Your code
LET vMore = peek('has-more',-1,'root');
LET vRowCount = peek('vid-offset',-1,'root');
LOOP;
You need to define RestConnectorMasterTable outside of your loop, then keep adding to that table. The breakdown of the table, i.e. the creation of the hs_email_last_send_date, hs_email_delivered etc. will then happen after the loop has finished.
LIB CONNECT TO 'HubspotContacts'
RestConnectorMasterTable:
NOCONCATENATE LOAD * INLINE [
has-more
];
do while vMore = 'True';
Trace($(vRowCount));
CONCATENATE (RestConnectorMasterTable) LOAD
*;
SQL SELECT
"has-more",
"vid-offset",
"__KEY_root",
//..
FROM "salesforceaccountid" FK "__FK_salesforceaccountid")
FROM "properties" PK "__KEY_properties" FK "__FK_properties")
FROM "contacts" PK "__KEY_contacts" FK "__FK_contacts")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(Url "https://api.hubapi.com/contacts/v1/lists/all/contacts/all?property=hs_email_delivered&property=sales...)",
HTTPHEADER "Authorization" "Bearer ABABABABABA");
let vMore =peek('has-more',0,'root');
let vRowCount =peek('vid-offset',0,'root');
loop
[hs_email_last_send_date]:
LOAD
[value],
[__FK_hs_email_last_send_date] AS [__KEY_properties]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_hs_email_last_send_date]);
//..
[root]:
LOAD
[has-more] ,
[vid-offset] ,
[__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
DROP TABLE RestConnectorMasterTable;
Hi @steeefan
Thank you very much for response
i tried with your script i get below error
let vMore =peek('has-more',0,'root');
let vRowCount =peek('vid-offset',0,'root');
loop
//////below updted script
My script is not complete and will not run. It's a simplifiation and contraction of the script you posted to illustrate my suggestion. You need to use your actual REST script within the loop that I showed.
i need to pass this variable value to the URL "vRowCount"
then only it will bring next set of record
Then make sure to add the variable $(vRowCount) to the URL of your request. See the HubSpot API documentation on how to achieve this.
Hi @steeefan Thank you for response
i added to URL
&vidOffset=$(vRowCount)"
the problem loop is not working based on other column (valriable)
loop need to repeat until has-more = False
Right, I see. Before entering the loop, you have to initiate the variable:
SET vMore = 'True';
Yes @steeefan initially it should be True and later it will read value from output
Hi @steeefan
i try using for loop
like below it works but i need while loop to stop the loop
can you suggest