I am trying (for the first time) to use APIs with Python Requests module.
I need to get some data from the API and parse it as JSON. I was able to successfully get the intended response with Postman for chrome, while testing the query.
However, when I try to execute the same code with Python the data gets encoded incorrectly. I have tried .encode('utf-8) .encode('utf-8) on my data with no success. I have read the articles on encoding in python howto (https://docs.python.org/2/howto/unicode.html) with no luck.
My code:
import requests r=requests.get("http://company.vtexcommercestable.com.br/api/oms/pvt/orders?per_page=100", headers={"Accept":"application/json","Content-Type":"application/json","X-VTEX-API-AppToken":"password","X-VTEX-API-AppKey":"testemail@gmail.com"});
data = r.json()
print r
The result:
{u'stats': {u'stats': {u'totalItems': {u'Count': 113, u'Min': 0.0, u'Max': 0.0, u'Sum': 0.0, u'Missing': 0, u'SumOfSquares': 0.0, u'StdDev': 0.0, u'Facets': {}, u'Mean': 0.0}, u'totalValue':
I would need to remove "u' .." and add keep latin characters (accents and "ñ")
Help is very much appreciated!