I would like to detect the end of the contact import process.

Hello.

I am running the following code in php/sdk

crm()->imports()->coreApi()->create()

Since the import process is executed asynchronously, we are trying to detect the end of the JOB on the PHP side.

If you have a sample implementation, please let me know.

Thank you

Yoshida

Hi, @吉田成一 :waving_hand: Thanks for the question! Hey, @tominal @skimura do you have any tips or a quick example you can share?

Best

@Jaycee_Lewis

Thanks for the support.

Hey @吉田成一,

I would check out the documentation regarding CRM imports. When you initiate one, it returns an ID. You can then query the API to check the “state” attribute of the import.

Hope that helps!

Mr. Johnson.

It was very informative and helpful.

Thank you.

I found a bug-like section.

$client = Factory::createWithAccessToken(env(“HUBSPOT_PRIVATE_APP_TOKEN_IMPORT”));

$resJobCreate = $client->crm()->imports()->coreApi()->create($csvFileObj, json_encode($import_request));

…

$client->crm()->imports()->coreApi()->getById($resJobCreate->getId());

Authentication error occurs in getById().

I have checked the SDK code.

getById() → getByIdWithHttpInfo() → getByIdRequest()

Within getByIdRequest()

// this endpoint requires API key authentication

$apiKey = $this->config->getApiKeyWithPrefix(‘hapikey’);

if ($apiKey ! == null) {

$queryParams[‘hapikey’] = $apiKey;

}

The above code retrieves the API key, but does not seem to handle the case where an access token is set.

// this endpoint requires API key authentication

$apiKey = $this->config->getApiKeyWithPrefix(‘hapikey’);

if ($apiKey ! == null) {

$queryParams[‘hapikey’] = $apiKey;

}

// this endpoint requires OAuth (access token)

if (!empty($this->config->getAccessToken())) {

$headers[‘Authorization’] = 'Bearer ’ . $this->config->getAccessToken();

}

I modified the SDK as above and it authenticated.

composer.json

“hubspot/api-client”:“^8.3”

Please help me to determine if this is a bug.

Hey @吉田成一,

I’ll tell you what I tell everyone who encounters major confusion with the SDK - I would use your own cURL or Guzzle requests. The PHP SDK has never been intuitive.

If you do determine that it is a bug, I would post an issue on the GitHub repository rather than the community forums. Those contributors will be able to help you more than we can.

Hope that helps!

Hey tominal.

Thanks for pointing that out.

I will report it to the repository.

Thank you.