Help

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

Solved
Jump to Solution
1283 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Cristian_Rojas1
4 - Data Explorer
4 - Data Explorer

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
Cristian_Rojas1
4 - Data Explorer
4 - Data Explorer

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
VictoriaPlummer
7 - App Architect
7 - App Architect

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

Cristian_Rojas1
4 - Data Explorer
4 - Data Explorer

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