App reviews, troubleshooting, and recommendations
I'm trying to update product json field with python, but something goes wrong. My idea was to take the product json file and change the fields that interested me without manually creating it for each product but got error 400 with put request. Also searching on internet I didn't find solution. here is my code:
import requests
import pprint
r = requests.get('https://shopify_api@myshop.myshopify.com/admin/api/2021-10/products.json')
file = r.json()
pprint.pprint(file)
print('\n\n')
file['products'][0]['variants'][0]['price'] = '30'
pprint.pprint(file)
print('\n\n')
id_product = file['products'][0]['id']
print(id_products)
headers = {"Accept": "application/json", "Content-Type": "application/json"}
url = 'https://shopify_api@myshop.myshopify.com/admin/products/' + str(id_products) + '.json'
print(url,'\n\n')
r = requests.put(url, json=file, headers=headers)
# r = requests.put(url, data=file, headers=headers)
print(r)
r = requests.get(url)
pprint.pprint(r.json())
someone know how can I fix it?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025