Instead of JSON, I get a set of numbers using the API. Said this compressed data.

Here is the request itself:

https://api.stackexchange.com/2.2/search?order=desc&sort=activity&intitle=corezoid&site=ru.stackoverflow.com 

By clicking everything works fine. If I use postman , too. I was told that postman automatically unzips compressed data.

The data that I get to the system via the API look like this:

 { "create_time": "2015.11.25 18:09:04", "change_time": "2015.11.25 18:09:04", "node_prev_id": "5655caeaf6c37670c306ddef", "status": "processed", "user_id": 5781, "data": { "__conveyor_api_return_description__": "Not valid http result json(<<31,139,8,0,0,0,0,0,4,0,171,86,202,44,73,205,45,86,178,138,142,213,81,202,72,44,142,207,205,47,74,85,178,74,75,204,41,78,213,81,42,44,205,47,73,140,207, 77,172,80,178,50,54,48,128,241,139,82,115,19,51,243,50,243,210,149,172,140,44,141,106,1,178,195,112,174,67,0,0,0>>)", "__conveyor_api_return_http_code__": 200, "__conveyor_api_return_type_tag__": "api_no_valid_json", "__conveyor_api_return_type_error__": "software" } } 
  • one
    You would explain what specific API function you are calling (and with what parameters), API SO has official documentation, you could find out. - VladD
  • one
    The text in question must be written in code, not a picture. - Qwertiy

2 answers 2

Which library / program do you request? Throw it out and forget, once in 2015, she cannot decode gzip .

Generally speaking, this is a bug on the stackoverflow api side. According to the HTTP standard, they should not compress the response without the request header Accept-Encoding: gzip - but compress. You can try to tell them about the bug.

Or you can request a new feature from the developers of your library.


If you need to decode the message without changing the client library and not waiting for corrections from the developers, then this "third-party service" is on any Linux: the gzip -d command will do what you need. Under Windows, you can put cygwin .

Also for many programming languages ​​there are libraries for decoding gzip. Unfortunately, you did not indicate what you are writing, so I can not advise you specifically.

    The server sends compressed data only if compression is supported on the client side.

    For example, the client sends a request when requesting GET / POST:

     Accept-Encoding: gzip, deflate, lzma, sdch 

    then the server can compress the data and send it before sending. At the same time, in the Response it will inform what compression method was used:

     Content-Encoding: gzip 

    The StackOverflow API, for some reason, ignores the user's request and compresses all data with gzip , so the problem is on the server side, all you have to do is unzip the data each time.