Legacy Dev Forum Posts

 View Only

Sign Up

Got Invalid PNG Data from getDownload API

  • 1.  Got Invalid PNG Data from getDownload API

    Posted 06-05-2025 18:32

    mikectint | 2024-09-20 00:43:48 UTC | #1

    In our application I try to download an image attachment of a message in a messaging conversation, using JavaScript SDK of the API "GET /api/v2/downloads/{downloadId}".

    let downloadId = "577048f050fe9354"; 
    let opts = { 
      "contentDisposition": "", 
      "issueRedirect": true, 
      "redirectToAuth": true 
    };
    apiInstance.getDownload(downloadId, opts)
      .then((data) => {
        console.log(`getDownload success! data: ${JSON.stringify(data, null, 2)}`);
      })
      .catch((err) => {
        console.log("There was a failure calling getDownload");
        console.error(err);
      });

    According to the documentation, if the request is successful it should return a JSON in the form of

    {
        "url":""
    }

    However, it returns a string that looks neither binary nor base64 string. (it starts with

    �PNG\r\n\n���\rIHDR��������\b���\tm\"H����PLTE��������������ȗ����̛����������������������Ҕ�����ccc��򧧧��배�yyyDDD�����ٍ��ppp���������QQQ---~~~������HHH���(((��YYY���999mmm\u000b\u000b\u000bVVVqpY]\\I����Û65*�⳧����r����թwv^+++��y���IH9**!�ɟ��i#\"����ټ��������ˮ������ɬ��x���\u000b\u000bff[BA3UTC$dcN����IDATx��]i{����e�!�\\6�Zn�\u000b����3�Mv7����\t���ҁZ0y���;k#�WU]U]]�\n�q�g�q�g�q�g�q�g�q�g�q�

    )

    And when I save the data into a PNG file and open it with a image viewer, it shows the error that it does not support this file format.

    My questions are:

    1. What format is the return string?
    2. How to convert the image into base64 string?

    system | 2024-10-20 06:43:43 UTC | #3

    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: 29435