API PHP SDK send 2 diffferents calls (and create 2 items)

The api (using the PHP SDK) sends 2 different calls when creating an object (a company, a task, a deal, etc.), which means that I end up with everything twice.

 $properties = [
 "name" => $customer->name,
 "domain" => $customer->website,
 "address" => $customer->street,
 "city" => $customer->city,
 "country" => $customer->getCountry(),
 ];

 $spoifc = new SimplePublicObjectInputForCreateCompany([
 "properties" => $properties,
 ]);

 $company = self::getFactory()->crm()->companies()->basicApi()->create($spoifc);
 return $company;

Hey, @TDev_ :waving_hand: Welcome to the community! Thanks for your question. I am not much a PHP-expert, but I’m happy to help. It sounds like the API call is being triggered twice. Check if the function calling `basicApi()->create()` is being invoked more than once unintentionally. You can also add logging right before and after the API call to confirm if it’s executed multiple times.

Have fun building — Jaycee!

Hello @Jaycee_Lewis , thanks for your answer, but after logging everywhere, I can’t find anything duplicate.

But what is strange is that our application on the Hubspot interface always notes 2 different “201” or “200” calls received (which by the way have an empty header and empty body but still work?)

Note that a previous implementation (not edited since months) in one of our projects that had the problem of duplicates for tasks, has started to have the bug for a few months for companies! So it’s not an implementation problem in this case.

So I fear that the problem comes either from a place that I missed in the SDK provided by Hubspot, or directly from the server side may be ?

The problem was that when we created the ‘Discovery’ object in the SDK, we added a Guzzle client, which was necessary in an older version of the API but not any more.

Sorry and thanks!