Help

Discover what data silos are costing your org in our commissioned Forrester study. Learn more

Insert url into an attachment field using sleiman/airtable-php

Topic Labels: API
Solved
Jump to Solution
1388 2
cancel
Showing results for 
Search instead for 
Did you mean: 

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!

1 Solution

Accepted Solutions

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);

See Solution in Thread

2 Replies 2

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.

image

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);