简体   繁体   中英

getting 400 error when trying to update Webex user through API

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] = "newemail123@example.com"

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

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

    user_details = json.dumps(user_details)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM