How to change product quantity field python

hi, I’m trying to change the stock availability of a product by accessing the ‘inventory_quantity’ variant without any effect. Also if I change it manually and execute the code it brings it back to 0. What should I use to change it permanently?

new_product = shopify.Product()
new_product.title = "Shopify Logo T-Shirt"
new_product.body_html = "**Test description**"
variant = shopify.Variant({
    'price': 9.99, 
    'sku': 98765, 
    'inventory_quantity': '45',
    # 'inventory_quantity': 45,
    'grams': '23',
    'requires_shipping': False})
new_product.variants = [variant]
new_product.save()

@federikowsky

you have to sue the put api instead of the post

https://shopify.dev/api/admin-rest/2021-10/resources/product-variant#top

See this shopify admin documents

@AvidBrio

sorry but the article you recommended to me, deals with the reallocation of an article in the event of the presence of multiple locations, or did I not find the solution? Anyway would you know the code to use to change the quantity? looking on the internet i saw shopify.InvetoryLevel () is the one i should use but it doesn’t work.

@federikowsky Hi here more detail api from shopify API

product and inventory manage different way read this article https://shopify.dev/api/examples/product-inventory

you have to use one more Shopify admin api