def dwolla_customer_document(dwolla_c_id,ach_post_data):
ach_req = f'customers/{dwolla_c_id}/documents'
client = dwollav2.Client(key = os.getenv('ACH_APP_KEY'),
secret = os.getenv('ACH_SECRET_KEY'),
environment = os.getenv('ACH_ENVIRONMENT')) # optional - defaults to production
app_token = client.Auth.client()
file_ach = ach_post_data['file'].read()
try:
dwolla_response = app_token.post(ach_req,file = file_ach, documentType = ach_post_data['documentType'])
except dwollav2.error.Error as e:
msg = e.body["message"] if not "_embedded" in e.body else e.body['_embedded']['errors'][0]['message']
return msg
object of type bytes is not json serializable and request itself not happened.
I tried with different answers like
i. file_ach = file_ach.decode('latin1')
ii. file_ach = file_ach.decode('utf-8', 'ignore')
In the both above cases I succesfully passed the request and got the response:
{
"status": false,
"message": "Invalid request Content-Type. multipart/form-data."
}
So, please help with the better approch in order to accomplish this.