Thanks Pankaj, I used this plus the pydundas library that @guillaume made several years ago (thanks!) to get to the below script, which works for a single account and update of the “country” multivalue attribute. I included it in case anyone wants to use for a similar exercise (keys and username/pwd information need to be updated accordingly).
However, when I try to use a csv file to populate the name and attribute (commented out below), the Country is being read in with extra characters and it is making the request fail. Have you run into this issue before? For example, if I have [‘Spain’] in the csv, it is being read in as when passed to the json. (had to paste as pictures because the post editor removes the )
from pydundas import Api, Session
#from csv import DictReader
import sys
import json
url = 'url'
user = 'apiaccount'
pwd = '***'
#with open('emails.csv', 'r') as read_obj:
# csv_dict_reader = DictReader(read_obj)
# for row in csv_dict_reader:
# name = row['Name']
# countries = row['Country']
name = 'email@domain.com'
countries = ['Spain','Morocco']
with Session(user=user, pwd=pwd, url=url, loglevel='warn') as d:
userinfo = d.post('Account/Name/', **{'json': name}).json()
userid= userinfo['id']
payload = [{"__classType":"dundas.account.CustomAttribute","key":"f23bebed-d0e2-4868-b89c-c9c4f2b77eb8","value":{"__classType":"dundas.account.CustomAttributeValue","attributeId":"f23bebed-d0e2-4868-b89c-c9c4f2b77eb8","values":countries}}]
updateatt = d.post('account/updatecustomattributesforaccount/' + userid,**{'json' : payload}).json()
print(updateatt)