function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shiv kumar 48shiv kumar 48 

Decompress json response using Apex

I am calling a rest api and it returns a response in compress format some like below , how to decompress this response in salesforce and read the data using apex
�\kw�6��+�~�9'��~x;����vb���l����%��D"�r���J��H��h�����x�P����0��4ɣ/����S�?/�NO���oa+&#124;����,�=�_�y�l'Q~�_O�{�!�� �Y��>�v��s�DI�<���%�������ur�����6&#124;G��Z[�<��G��g&#124;sr\�� oY7Φ�8GV�z�2)�,�}�WeA��*\p�������q�/�4��H}���8 �h����nK�Z�>��3�=Ӎ��M/ZN��9��=6^t�d�#{?~8�?짋3����`؃�0�����Z������iڙ�s؏�'Q�R�&#124;%~��x���x���]e�_�DY�� ��O�i� �=4f�-��-t�i0}�f�y4�&#124;����oNn�՜�FA���ӈ��t���FGW�t���h�>�?��y���A�ʦ��!�/#�g�}�,�,�%M�B��;�mi�D��l���ۚ�k�U��V�����.6㤓�Y&#124;�w��m_�4��Q��$�&v�Z�GKX��]'q�d�gƩ�����~��l(�ű��s��D3V�����$&#124;�����Χ�9g&;�<�^�E�f�p����Z[[k�;����<�)�GԷ�������>}�n��mξQ8�5��x��#�����O�=��L�9��^x?��9�N��:����)��.��h�:Ϩ�h�\W�j!�D�b�ʒ�V��m�j�v�Im�E뇊B_Yvu��r� �� F�܂w�����(�׷w'z[�;aQ2�L=ݝ\O-������%�`O�U��e�������n�3��������u��sݎ�������s�cy����V�A�g�5���`�׺5�z��uj>0���v^��y�����:�>�����~�e�v��V��Y<�܉�j��,֗��c�k�k�����.f V�\F��!���ӯ+��H� �m��j���) �s���ʶJf__^��<�m���ؚ湮T\�)~��"J�*Em3������.��]�����`�����0ۡ�__p��`�m��훠�iK��Ɍ�g���J�r,�����)s�6ӱX�욆���{��zqİ�ӧmO�;%����CS�x<f�t&OCTX,�Ҋ��`CTO�A�2h�����O��&#124;Z�Y�sL�t\ͷ=?�%�k�_�O{�.������7�ۭ�ǃ�;�ǃ�������B9�oX�c�VY9�n���8�ˬI��f[�-C�O2~Q��Z��!�4�Ru[��1q����դol5��Ф:7��Mì^��V��z#B��*H��zy�[Wj�&#124;^��+�co���P��~a���MV ́u�� LU�OVA ��˓�*�R9���d]�����:'����yK�6mY�GԒZ��J�{LlY���?"*��V��b���m��},~�u�6�a�.�^�4� Se����BQ�
AnudeepAnudeep (Salesforce Developers) 
If System.debug(response.getBody()); is giving this response, you can try parsing it
 
JSONParser parser = JSON.createParser(response.getBody());
       while (parser.nextToken() != null) {

              System.debug('parser.getCurrentName() => '+ parser.getCurrentName());
       System.debug('parser.getCurrentToken() => '+ parser.getCurrentToken());
       System.debug('parser.getText() => '+ parser.getText());

        }

If it doesn't work, I recommend checking whether your post request is properly formed

1) Go to postbin.defensio.com/ and click Create a new PostBin
2) Use the URL obtained as the endpoint of the request.
3) Make a request and check the URL back.

​​https://help.salesforce.com/articleView?id=000321529&language=en_US&type=1&mode=1

Also, You have to ensure when a request is sent in compressed format, the following fields are present in the headers:

Content-Encoding: gzipAccept-Encoding: gzip

There have been relevant discussions in the past around this, for example, see this post
shiv kumar 48shiv kumar 48
Hi @Anudeep ,
This is when salesforce post any request to external system using compressed format  and that external system sends any response then response is decompressed using this setting.
But here we are not posting anything, its a GET request to external system  not POST.