Skip to content

TypeError a bytes-like object is required, not 'str' #7

Description

@llybin

voximplant/apiclient/client.py in add_user at line 1743

if user_custom_data is not None:
    params['user_custom_data']=user_custom_data

res = self._perform_request('AddUser', params)
if "error" in res:  <---- TypeError a bytes-like object is required, not 'str'
    raise VoximplantException(res["error"]["msg"], res["error"]["code"])

return res
def _perform_request(self, cmd, args):
    params = args.copy()
    params["cmd"] = cmd
    headers={'Authorization': self.build_auth_header()}
    result = requests.post("https://{}/platform_api".format(self.endpoint), data=params, headers=headers)
    if result.headers.get("content-type","").split(";")[0].lower() == "application/json":
        return json.loads(result.text)
    else:
        return result.content   <------ not dict here on server error for example

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions