APIs & Integrations

nthomson6
参加者

API Key not showing up in request paging link

解決

Hi there, 

 

I'm currently trying to pull companies from hubspot into azure data factory using "hapikey". When I make the initial request I include the "hapikey" but when I receive the request, it doesn't have the "hapikey" in the "paging.next.link".

 

Is there a reason for this? If I include "limit" as an argument it's returned in the next page link but the "hapikey" isn't.

 

Nic

0 いいね!
1件の承認済みベストアンサー
webdew
解決策
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

API Key not showing up in request paging link

解決

Hi @nthomson6 ,

Actually, you have to save hapikey into db or any where because hapikey not returning on next page link via using api and next page offset id also need to add in database. Function add in cron job for iteration.

I have a php code for this, please have a look.
<?php

$from_hapikey = 'demo';
$no_of_page = 200;
$offset = DB::table('offsets')->where('id',1)->value('offset');
if($offset != 'done'){

$results = DB::table('offsets')->where('id','>',$offset)->paginate($no_of_page);
$offset_update = 0;

$results = // data get from companies api

if(!empty($results)){
$offset_update = // add last page link id here
} else {
DB::table('offsets')->where('id',1)->update(['offset'=>'done']);
}
foreach ($results as $key => $value) {
// sync here.
}
}
?>


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

元の投稿で解決策を見る

3件の返信
webdew
解決策
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

API Key not showing up in request paging link

解決

Hi @nthomson6 ,

Actually, you have to save hapikey into db or any where because hapikey not returning on next page link via using api and next page offset id also need to add in database. Function add in cron job for iteration.

I have a php code for this, please have a look.
<?php

$from_hapikey = 'demo';
$no_of_page = 200;
$offset = DB::table('offsets')->where('id',1)->value('offset');
if($offset != 'done'){

$results = DB::table('offsets')->where('id','>',$offset)->paginate($no_of_page);
$offset_update = 0;

$results = // data get from companies api

if(!empty($results)){
$offset_update = // add last page link id here
} else {
DB::table('offsets')->where('id',1)->update(['offset'=>'done']);
}
foreach ($results as $key => $value) {
// sync here.
}
}
?>


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

nthomson6
参加者

API Key not showing up in request paging link

解決

This is an interesting response, I was doing this on azure data factory (frustratingly I use python normally and it's very simple in python), iterating through the "after" parameter in a similar way to how you describe (I think since I'm not great with php) was able to sort it. 

 

Thanks!

dennisedson
HubSpot製品開発チーム
HubSpot製品開発チーム

API Key not showing up in request paging link

解決

@nthomson6 

Have you thought about using OAuth as an alternative?  That is what we encourage developers to use

@johnelmer , do you have any suggestions?

0 いいね!