Hello all,
I’m trying to update a hubdb via API v3. When using POST, all data flows as expected and the database is populated with the proper data in the proper columns.
However, I don’t want to duplicate the information every time I run the script, and it should run at least every day.
I’ve tried doing PATCH, PUT and DELETE methods on my code, each with varying errors - correlation errors, 405 errors, 401 errors. I cannot, for the life of me, figure out what’s going on here and perhaps someone came across this issue and has a fix for it?
Here’s where my code stands at the minute:
$payload = json_encode([ ‘values’ => [ ‘name’ => $currency, // Use the column name ‘moeda’ ‘valor_compra’ => (string)$entry[‘buyValue’], // Use the column name ‘valor_compra’ ‘valor_venda’ => (string)$entry[‘sellValue’], // Use the column name ‘valor_venda’ ‘data’ => (string)$entry[‘lastUpdateDate’], // Use the column name ‘lastUpdateDate’ ] ]); $ch = curl_init($updateUrl); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer '.$hubspot_api_key, ‘Content-Type: application/json’, ]); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘PUT’); // Use PATCH to update the row curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); // Payload with null values curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // Get the HTTP response code curl_close($ch); echo “PATCH Response: $response, HTTP Code: $http_code\n”;
Bare in mind that when doing the almost exact same code in POST instead of PATCH, it goes through. Same $payload, same auth key and Bearer method. Any suggestions? Thanks in advance