Error 400403 Invalid value: JSON body

I am trying to create user using sendbird API
I am using python to make the API call

Following is my code -

import json
import requests

    url = 'https://api-someappidhere.sendbird.com/v3/users'

    headers = {
        'Content-Type' : 'application/json; charset=utf8',
        'Api-Token' : 'secondaryApiToken'
    }

    data = {
        'user_id' : 'someuserId',
        'nickname' : 'somenickname',
        'profile_url' : ''
    }

    try:
        apiResponse = requests.post(url, headers=headers, data=data)
        apiResponse = apiResponse.json()
        
        return response

    except Exception as error:
        print(error)

I am getting the following response -
    {
    "hasError": false,
    "result": {
        "message": "Invalid value: \"JSON body.\".",
        "code": 400403,
        "error": true
    }
}

References -
https://docs.sendbird.com/platform/quick_start
https://docs.sendbird.com/platform/error_codes

JSON syntax is different from Python syntax in that it requires double quotes, not single quotes.
Change them to double quotes and see if you’re still have problems.

data = {
        "user_id" : "someuserId",
        "nickname" : "somenickname",
        "profile_url" : ""
    }
1 Like