getting 400 error when trying to update Webex user through API

434 Views Asked by At

I'm trying to update a value received from API in JSON and send it back. I updated the value as the following code but when I try to send it back "PUT" I get error 400 Bad Request

the API can be found here: Webex Update a Person API

could someone help me figure what am I doing wrong?

thanks a lot

def get_userID(user_id):
    session = HTMLSession()
    header = {
        "Authorization": "Bearer %s" % token,
        "Content-Type": "application/json",
    }
    session.get(
        f"https://webexapis.com/v1/people/{user_id}",
        headers=header,
        verify=True,
    )
    user_details = webex_user_details.json()
    user_details["emails"][0] = "[email protected]"

    webex_user_details = session.put(
        f"https://webexapis.com/v1/people/{user_id}",
        headers=header,
        data=user_details,
        verify=True,
    )
    print(webex_user_details)

1

There are 1 best solutions below

0
On

I figured it out that I need to dump the new data as JSON after updating

    user_details = json.dumps(user_details)