Lets say I have this json:
{'name': 'jon',
'id' : '20304',
'pets': [{'name': 'sparkles',
'age': 10
'stats': {'weight':10,
'favetoy':'cottonball'
'color': 'green'}
}]
}
Im trying to modify the 'color' parameter inside stats in a PUT request, by doing something like:
url = "https://....." #hostname+api url
payload = {
'pets': [{'stats:{'color':'red}}]
}
response = requests.put(url, json=payload, headers=headers)
#assume headers defined elsewhere.
And while it is changing the color to red, it's also changing the whole 'pets' array (name, age) to nothing, which makes sense, since my request body doesnt include anything for the other params within the array. But I just want to change the color to red, while keeping the rest the same...but I don't see how since its nested within the array... what would I include in the request body instead?
TLDR: I just want to make an api put request to modify 'color' and keep everything else the same in the same way you do with 'id' or 'name'.
Any ideas??