Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
llybin opened this issue Jun 6, 2022 · 1 comment
Open

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

llybin opened this issue Jun 6, 2022 · 1 comment

Comments

@llybin
Copy link

llybin commented Jun 6, 2022

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
@llybin
Copy link
Author

llybin commented Jun 6, 2022

POST https://api-node3.voximplant.com/platform_api [502]
{
reason: Bad Gateway
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant