GET attachment via api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Russ
    Senior Member
    • Feb 2022
    • 423

    GET attachment via api

    Hey guys, please help, can't get attachment (VOIP call recording)



    PHP Code:
    $callRecordingDetails = $this->espoAPIService->getCallDetails($call->id);
    
    public function getCallDetails($id, $useCache=false){
        return $this->apiRequest(Client::METHOD_GET, 'Call/' . $id, null, $useCache);
    }​
    
    $audioFileContents = $this->espoAPIService->getAttachmentContent($callRecordingDetails->voipRecordingFileId);
    
    public function getAttachmentContent($id){
        return $this->apiRequest(Client::METHOD_GET, 'Attachment/file/' . $id);
    }// returns null, when I am doing (Attachment without /file):
    public function getAttachmentContent($id){
        return $this->apiRequest(Client::METHOD_GET, 'Attachment/' . $id);
    }
    I am getting details about the attachment


    Please help me how, do I actually get the file contents?

    Thanks
    Last edited by yuri; 04-03-2024, 06:52 AM.
  • yuri
    Member
    • Mar 2014
    • 8452

    #2
    It's the API client that does not return raw contents.

    Use our official client https://github.com/espocrm/php-espo-api-client or any other API client library like Guzzle.
    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

    • Kharg
      Senior Member
      • Jun 2021
      • 410

      #3
      Hi Russ are you trying to get the file content in base64?

      Comment

      • Russ
        Senior Member
        • Feb 2022
        • 423

        #4
        Originally posted by Kharg
        Hi Russ are you trying to get the file content in base64?
        Raw .wav content, I guess it could be in base64

        Comment

        • Russ
          Senior Member
          • Feb 2022
          • 423

          #5
          Guzzle helped, thanks yuri

          Comment

          Working...