I'm trying to update an object metadata through Google Cloud Storage using Python aiohttp PATCH request, code attempt as follow.
async def send_init_value_map(sequence_name):
"""Update a blob's metadata."""
initial_value_map = {"metadata", "value": {'test':0}}
async with ClientSession() as session:
await session.patch(url=api_url, headers=headers, data=initial_value_map)
return initial_value_map
The url
and headers
in the patch request are good, as they worked in GET request. However, I'm not sure if I'm passing the data
field right, the change didn't take effect.
Info on PATCH within aiohttp documentation is limited, as the format for data
field input is not specified.
I'm not going with the Google API Client option because I need to use aiohttp for async function implementation.
Thank you in advance for you inputs.
I had to convert the data dictionary to json first. After that, the data was successfully updated.
async def send_init_value_map(sequence_name):
"""Update a blob's metadata."""
initial_value_map = {"metadata", "value": {'test':0}}
async with ClientSession() as session:
await session.patch(url=api_url, headers=headers, data=json.dumps(initial_value_map))
return initial_value_map