I am trying to assignment variables to the following json from a rest API:
.json
https://shopify.dev/docs/admin-api/rest/reference/products/product
.py
response = requests.get("https://{0}{1}".format(session.get("shop"), endpoint), headers=headers)
print(response)
#If connection has been successfull ...
if response.status_code == 200:
products = json.loads(response.text)
for product in products:
###PRINT VARIABLES####
print(product['id']
print(product['title'])
print(product['title']['variants']['product_id'])
The above however returns the following error.
KeyError: 'title'
I have further tried;
print(products['product']['title']
print(product(product).title
and various others with no success.
Any help parsing this json would be appreciated.
Thanks!
",after8GBresponse.textbefore doingjson.loads"