momoapi-python icon indicating copy to clipboard operation
momoapi-python copied to clipboard

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

Open oquidave opened this issue 6 years ago • 8 comments

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]: ''

oquidave avatar May 23 '19 11:05 oquidave

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

mossplix avatar May 23 '19 12:05 mossplix

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

mossplix avatar May 27 '19 15:05 mossplix

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

oquidave avatar May 27 '19 16:05 oquidave

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.

raybesiga avatar May 28 '19 20:05 raybesiga

@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

jamesidw avatar Sep 27 '19 08:09 jamesidw

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

raybesiga avatar Sep 29 '19 20:09 raybesiga

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

raybesiga avatar Dec 04 '20 09:12 raybesiga

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

crukundo avatar Feb 18 '22 22:02 crukundo