0

I am trying to POST new XML resources to prestashop using Python, but it lists all the resources instead.

Assume that **URL_PRODS **and **CLAVE **are properly defined

def postNewProduct():
    newProduct = requests.get(URL_PRODS, auth = HTTPBasicAuth(CLAVE,''), params = {'schema':'blank'})

    product = newProduct.find('product')
    
    product.find('id').text = '1000'
    product.find('id_manufacturer').text = '100'
    product.find('reference').text = 'AAAAAA'
    product.find('width').text = '10'
    product.find('height').text = '10'
    product.find('depth').text = '10'
    product.find('weight').text = '10'
    product.find('price').text = '1'

    try:
        xml = ElementTree.tostring(product)
        req = requests.post(URL_PRODS,data=xml,auth=HTTPBasicAuth(CLAVE,''),headers={'Content-Type':'text/xml'})

        return req.text
    except Exception as e:

        return e
    

This code should create a product resource but it lists all the resources instead as if it was a GET

Mad Rid
  • 1
  • 1
  • 2
  • 1
    The request.get() doesn't parse the xml resonse, compare this answer [here](https://stackoverflow.com/a/18308594/12621346) – Hermann12 Feb 21 '23 at 20:39

0 Answers0