unable to decode Python web request

前端 未结 1 1972
遥遥无期
遥遥无期 2021-01-11 15:33

I am trying to make web request to my trading account . Python is unable to decode the web request. Web request is successful with code - 200.

Here is the code below

相关标签:
1条回答
  • 2021-01-11 15:40

    According to the response.headers (that you did not provide, but that are easily recoverable by running your code), the response is encoded using Brotli compression (Content-Encoding': 'br'). You can decompress it with brotlipy:

    import brotli
    brotli.decompress(response.content)
    #b'{"status":"success","data":[{"placed_by":"XE4670","order_id":"180331000000385",  
    #"exchange_order_id":null,"parent_order_id":null,"status":"REJECTED",
    #"status_message":"ADAPTER is down","order_timestamp":"2018-03-31 07:59:42", 
    #"exchange_update_timestamp":null,...}
    

    Now, it's JSON, as promised ('Content-Type': 'application/json').

    0 讨论(0)
提交回复
热议问题