Python Forum
Unable to convert request response.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to convert request response.
#1
Hi,

I'm trying to convert a response which I think is in Unicode? I am using the requests library to get data from an API. I am running the following:

import requests

url = "https://api-football-v1.p.rapidapi.com/v3/standings"

querystring = {"season":"2020","league":"187"}

headers = {
    'x-rapidapi-key': "asdfasdfasdfasdfasdf",
    'x-rapidapi-host': "api-football-v1.p.rapidapi.com"
    }

response = requests.request("GET", url, headers=headers, params=querystring)
strResponse = response.text
utf8string = strResponse.encode("utf-8")
print(utf8string)
It doesn't work though. In that response, I have the likes of:

{"id":10735,"name":"CR B\\u00e9ni Thour"}
But that should come back as:
{"id":10735,"name":"CR Béni Thour"}

Not sure what I'm doing wrong?

Many thanks!
J
Reply


Messages In This Thread
Unable to convert request response. - by johnboy1974 - Apr-04-2021, 08:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to request image from FORM Data usman 0 1,079 Aug-18-2022, 06:23 PM
Last Post: usman
  request.get to read large response pythonlearner1 7 3,559 Apr-05-2022, 08:21 PM
Last Post: pythonlearner1
  how can I correct the Bad Request error on my curl request tomtom 8 5,412 Oct-03-2021, 06:32 AM
Last Post: tomtom
  Empty response to request causing .json() to error t4keheart 1 10,398 Jun-26-2020, 08:35 PM
Last Post: bowlofred
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 4,075 Jun-18-2020, 08:07 AM
Last Post: buran
  Unable post request to AWS elasticsearch service Rupini 0 1,972 May-18-2020, 08:27 AM
Last Post: Rupini
  Issues parsing the response from a request garnold 3 2,728 May-14-2019, 12:39 PM
Last Post: snippsat
  Unable to print the exact Float values when I convert LIST to Sequence of Tuples? preethamalluri 1 2,554 Jul-12-2018, 09:03 AM
Last Post: buran
  unable to convert text file in dictionary purnima1 6 4,559 Apr-02-2018, 07:44 AM
Last Post: purnima1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020