Get Image using API
Collapse
X
-
Dear,
Im trying to get the image of an record via the API. All data comes in except the image:
I have tried: https://docs.espocrm.com/development/api/attachment/ without success.
This is the script:
Code:// Fetch product information $response = $client->request('GET', 'Product'); if (!$response || !isset($response['list'][0])) { die("Failed to retrieve product information."); } $product = $response['list'][0]; $imageUrl = $url . "/api/v1/Attachment/file/" . $product['id'];
PHP Code:// Fetch product information
$response = $client->request('GET', 'Product');
if (!$response || !isset($response['list'][0])) {
die("Failed to retrieve product information.");
}
$product = $response['list'][0];
$imageUrl = $url . "/api/v1/Attachment/file/" . $product['image_id']; // replace image with name of the field where you store the product image.
Leave a comment:
-
The request in your code will basically look similar to this: $imageUrl = $url . "/api/v1/Attachment/file/" . $product['imageId']; where "imageId" is the name of the field you have added to upload the photo of the product make sure you will use imageId not just imageLast edited by Jakub Grufik; 09-13-2023, 01:22 PM. -
Aight, then go to random product open its detail and then change the URL to this one https://your_crm_url.eu/api/v1/Produ...of_the_product and over there you will find the id of the image you are looking for and then you can use this ID in the API request to get the attachment -
Thanks for your reply.
The entity i want to get an image from is the Product entity from the salespack extension. I have added an field in the entity to upload an image with the product.
Again thanks!Leave a comment:
-
Hello, what exactly do you mean by image of an record? What is the records entity type? Also in the code where you are trying to get an attechment via API you need to use ID of the attachment not the ID of the product itself.Leave a comment:
-
Get Image using API
Dear,
Im trying to get the image of an record via the API. All data comes in except the image:
I have tried: https://docs.espocrm.com/development/api/attachment/ without success.
This is the script:
Code:// Fetch product information $response = $client->request('GET', 'Product'); if (!$response || !isset($response['list'][0])) { die("Failed to retrieve product information."); } $product = $response['list'][0]; $imageUrl = $url . "/api/v1/Attachment/file/" . $product['id'];
Tags: None
Leave a comment: