APIs & Integrations

MPenn6
Participant

PHP Updating Line Item Results in 403 Forbidden

I'm writing a couple PHP functions to create and/or modify a deal's line item. Everything is working great except for the /crm/v3/objects/line_items/ endpoint.

 

I CAN successfull edit a line item's price using Postman. Also, using the Test Call  function directly from the API Endpoint documentation page (https://developers.hubspot.com/docs/api/crm/line-items).

 

My PHP code is direct from the successful test call that was generated in the endpoint documentation

 

 

require('app-top.php');
use HubSpot\Factory;
use HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInput;
use HubSpot\Client\Crm\LineItems\ApiException;

$client = Factory::createWithApiKey(HUBSPOT_API_KEY);

$properties = [
    "price" => "123.00"
];
$SimplePublicObjectInput = new SimplePublicObjectInput(['properties' => $properties]);
try {
    $apiResponse = $client->crm()->lineItems()->basicApi()->update($SimplePublicObjectInput, "2388052385", null);
    var_dump($apiResponse);
} catch (ApiException $e) {
    echo "Exception when calling basic_api->update: ", $e->getMessage();
}

 

 

 

This code returns a 403 Forbidden error. The exact error code is:

 

 

 

Exception when calling basic_api->update: [403] Client error: `PATCH https://api.hubapi.com/crm/v3/objects/line_items/%7B%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22price%22%3A%20%22123.00%22%0A%20%20%20%20%7D%0A%7D?hapikey=xxxxx` resulted in a `403 Forbidden` response: 

 

 

 

 

It appears to be a message from Cloudflare. My IP address is not blocked (because all of my other API calls work OK). I'm thinking that maybe Cloudflare sees something wrong with the format of the data. I think this is the only PATCH call that I am using. Maybe there is an issue with that? I'm not sure. Any ideas? code working in the endpoint documentation test callcode working in the endpoint documentation test call

0 Votes
1 Réponse
dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

PHP Updating Line Item Results in 403 Forbidden

@webdew ,

Any thoughts on what might be going wrong here?

0 Votes