Help API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 3ng3l64
    Junior Member
    • Apr 2020
    • 2

    Help API


    excuse my bad english, first of all, I have a problem when I send images from a form via api, when I send an image of less than 20kbs it loads me without problem in the crm with the contact data, but if the image has a weight of 50kb or higher I have the following error:

    Exception: EspoClient: Unknown Error in /home/website/public_html/forms/EspoApiClient.php:141 Stack trace: #0 /home/website/public_html/forms/procesar.php(19): EspoApiClient->request('POST', 'Attachment', Array) #1 {main}


    include 'EspoApiClient.php';
    $client = new EspoApiClient('URLESPO');
    $client->setApiKey('APIKEY');
    $client->setSecretKey('SECRETKEY' );

    try {
    $response = $client->request('POST', 'Attachment', [
    'name' => $_FILES['file']["name"],
    "field" => "fotoDeCedula",
    "role" => "Attachment",
    "parentType" => "Contact",
    'type' => $_FILES['file']['type'],
    'size' => $_FILES['file']['size'],
    'file' => ',' . (base64_encode(file_get_contents($_FILES['file']['tmp_name'])))
    ]);
    } catch (Exception $e) {
    echo $e;
    }


    check the spouse log and it throws me this

    [2021-03-25 02:04:58] Espo.ERROR: (400) POST /{ESPOCRM}/api/v1/Attachment; line: 85, file: /home/website/public_html/{ESPOCRM}/application/Espo/Core/Controllers/Record.php [] []


    Thank you very much I hope someone can help me with my problem
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    The error is thrown here: https://github.com/espocrm/espocrm/b...Record.php#L85

    I suggest debugging. This error looks weird to me.

    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...