1

How is this possible that the output color is BLACK in both members of array ? What am I missing here.

Code :

url= u'https://openapi.etsy.com/v2/listings/{0}/inventory/'.format(listing_id)
r = requests.get(url=url, auth=OAuth1(ETSY_CLIENT_KEY, ETSY_CLIENT_SECRET,
                ETSY_RESOURCE_OWNER_KEY_READ, ETSY_RESOURCE_OWNER_SECRET_READ,
                signature_type='auth_header'))

rsp = json.loads(r.text)
rsp['results']['products'][0]['sku']=sku

rsp['results']['products'][0]['property_values'] = [
    {'property_id':513, 
    'property_name':'Custom property', 
    'values': ['red']}
    ]

rsp['results']['products'].append(rsp['results']['products'][0])

rsp['results']['products'][1]['property_values'] = [
    {'property_id':513, 
    'property_name':'Custom property', 
    'values': ['black']}
    ]
rsp['results']['products'][1]['sku']='1' + str(sku)

Unwanted output :

rsp['results']['products'][0]['property_values'][0]['values'][0]
'black'
rsp['results']['products'][1]['property_values'][0]['values'][0]
'black'

The output I need

rsp['results']['products'][0]['property_values'][0]['values'][0]  red 
rsp['results']['products'][1]['property_values'][0]['values'][0]  black
Have a nice day
  • 1,007
  • 5
  • 11
anelBavari
  • 29
  • 3

0 Answers0