Apr 07, 2020 11:23 AM
Hi, I’m using sleiman/airtable-php to integrate airtable with my website, the problem that I’m having right now is inserting a public url where my image is hosted to the attachment field of the table; this is the code:
$url = "<url-of-the-image>";
$attachment = array('url' => $url);
$update_details = array(
"ID Verification" => $attachment,
);
$update = $airtable->updateContent("Applications/$record_id", $update_details);
And I get this error:
[error] => stdClass Object
(
[type] => INVALID_ATTACHMENT_OBJECT
[message] => Invalid attachment object for field ID Verification: "<url-of-the-image>"
)
I have also tried to make the $attachment
variable an object like this:
$attachment = (object) [ 'url' => $url ];
Or do I have to define $attachment
differently or ‘sleiman/airtable-php’ doesn’t support attachment fields?
Help!
Solved! Go to Solution.
Apr 07, 2020 07:07 PM
Was able to find the answer after searching a little bit more, I needed to add the $attachment
variable in one more array:
$url = "<url-of-the-image>";
$attachment = array('url' => "$url");
$update_details = array(
"ID Verification" => [$attachment],
);
$update = $airtable->updateContent("Applications/$record_id", $update_details);
Apr 07, 2020 06:26 PM
I think so. If you look at your base structure in airtable.com/api you’ll see the attachment field has different properties, including a URL property, which is probably where you want to write the URL to.
Apr 07, 2020 07:07 PM
Was able to find the answer after searching a little bit more, I needed to add the $attachment
variable in one more array:
$url = "<url-of-the-image>";
$attachment = array('url' => "$url");
$update_details = array(
"ID Verification" => [$attachment],
);
$update = $airtable->updateContent("Applications/$record_id", $update_details);