sparkplug / momoapi-python

MTN MoMo API Client Library for Python
MIT License
47 stars 55 forks source link

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #24

Open oquidave opened 5 years ago

oquidave commented 5 years ago

Why I am getting JsonDecodeError with disbursements even when the http response is 202? This is what I am getting back after calling transfer method;

return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is the data I am pushing through;

headers
Out[9]: 
{'X-Target-Environment': 'sandbox',
 'Content-Type': 'application/json',
 'Ocp-Apim-Subscription-Key': 'hidden',
 'X-Reference-Id': 'hidden'}
data
Out[10]: 
{'amount': '600',
 'currency': 'EUR',
 'externalId': '123456789',
 'payee': {'partyIdType': 'MSISDN', 'partyId': '256772123456'},
 'payerMessage': 'dd',
 'payeeNote': 'dd'}

And these are the values of the resp variable;

resp
Out[20]: <Response [202]>
resp.headers
Out[21]: {'Content-Length': '0', 'Date': 'Thu, 23 May 2019 11:08:30 GMT'}
resp.status_code
Out[22]: 202
resp.text
Out[23]: ''
mossplix commented 5 years ago

Its trying to decode an empty response as JSON. Let me file this as a bug and push a fix

mossplix commented 5 years ago

Hey, I wasn't able to reproduce this. How are you getting the error?

oquidave commented 5 years ago

The data I am pushing to the api and what I am getting back is all listed above.

raybesiga commented 5 years ago

Hi @oquidave please help us help you by telling us how to recreate your error. The "New Issue" template for "bug" details how to do this.

jamesidw commented 5 years ago

@raybesiga @mossplix Since this issue wasn't closed, I'll add to it instead of creating a new one.

Issue can be reproduced simply by installing simplejson

See POC here

raybesiga commented 5 years ago

Thanks for adding to this @jamesidw We shall look into it this week.

raybesiga commented 3 years ago

@jamesidw @oquidave did you ever get around this issue?

crukundo commented 2 years ago

I am having the same problem now with client.requestToPay(). Was this looked into?