Legacy Dev Forum Posts

 View Only

Sign Up

401 when uploading attachment to email reply

  • 1.  401 when uploading attachment to email reply

    Posted 06-05-2025 18:29

    JavierVRT | 2023-12-07 12:29:54 UTC | #1

    Hi, I'm trying to attach a file to an email reply.

    I found here a post with a comment that shares link about it, but it does not work: https://developer.genesys.cloud/forum/t/uploading-attachments-onto-an-email/2953/3

    Then I tried the example in this page: https://developer.genesys.cloud/analyticsdatamanagement/uploads/upload-email-attachments But I receive error 401. I make call with my Genesys token, a conversationId (whose last message is a reply) and this blob data through FormData file field:

    			let welcome = new Uint8Array([89, 101, 108, 99, 111, 109, 101]);
    			let blob = new Blob([welcome, ' to ', 'W3Docs'], {type: 'text/plain'});

    What am I doing wrong?


    tim.smith | 2023-12-07 15:17:20 UTC | #2

    JavierVRT, post:1, topic:23573
    But I receive error 401

    A 401 error means you failed to provide a valid auth token. That means you either didn't provide one at all, the header is malformed, or the token isn't valid (i.e. expired).


    JavierVRT | 2023-12-07 17:22:25 UTC | #3

    I have found the problem. Just was that the example hasn't whitespace between 'Bearer' and the token and I didn't noticed until now.

     Authorization: 'Bearer' + authToken

    With this small fix and targeting to the correct domain, it works fine and file is attached to the next sent reply.

    By the way, there is any way to specify if is it an inline image?


    tim.smith | 2023-12-07 17:32:25 UTC | #4

    Thanks for reporting back, we'll get the example fixed.

    JavierVRT, post:3, topic:23573
    By the way, there is any way to specify if is it an inline image?

    I believe uploaded attachments are only just that. However, you should be able to use base64 encoded images in the HTML body of the email without using attachments. I haven't done that with Genesys Cloud, but that's a normal thing to do with HTML email in general.


    vpirat | 2023-12-07 21:26:49 UTC | #5

    Hi Javier,

    By the way, there is any way to specify if is it an inline image?

    Add the attribute InlineImage: true in the body of your request.

    Example:

    ------WebKitFormBoundary1
    Content-Disposition: form-data; name="conversationId"
    
    44405d30-3028-4d02-b47b-011459a13463
    ------WebKitFormBoundary1
    Content-Disposition: form-data; name="file"; filename="myFile.png"
    Content-Type: image/png
    
    
    ------WebKitFormBoundary1
    Content-Disposition: form-data; name="inlineImage"
    
    true
    ------WebKitFormBoundary1--

    Regards, V.P.


    system | 2024-01-06 21:27:38 UTC | #6

    This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 23573