APIs & Integrations

kishan
Participant

Hub api Update row query

I want to update row multiple columns at a time through hubapi:
i am following this method : https://developers.hubspot.com/docs/methods/hubdb/v2/update_row

I have created PHP CRUD file perfectly and all other things works like create-row,delete-cell,update-row-cell.
but this one thing throws error.

ERROR:

{
status: "error",
message: "You must pass in a row for this operation.",
correlationId: "",
requestId: "
",
}

Here is my code of PHP CURL:

$requestUrl = sprintf(
'https://api.hubapi.com/hubdb/api/v2/tables/%s/rows/%s?hapikey=%s',
$tableId,
$rowId,
$apiKey
);

$array = array( "2" => "drdr");

$array1 = array("values"=>$array);

$dataJson = json_encode($array1);

$ch = curl_init($requestUrl);
$dataJson = json_encode($data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataJson);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
]);
$response = curl_exec($ch);

echo $response;

if (!$response) {
trigger_error(curl_error($ch));
}

curl_close($ch);

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Hub api Update row query

Hi @kishan,

This may sound like a basic question, but is it possible that there isn't a value for $rowId when $requestUrl is assigned? If $rowId were null, that would explain the error. To help me troubleshoot, could you try logging the value of $requestUrl right after you assign it?

0 Upvotes