jczic / MicroWebCli

A micro HTTP Web client for MicroPython (used on Pycom modules & ESP32)
https://microwebcli.hc2.fr
MIT License
54 stars 16 forks source link

The o parameter of the JSONRequest function #7

Open iBigDane opened 1 year ago

iBigDane commented 1 year ago
auth   = MicroWebCli.AuthBasic('toto', 'blah123')
result = MicroWebCli.JSONRequest('http://my-web-site.io/my-api/user/12', auth=auth)
print('User name is %s %s' % (result.firstname, result.lastname))

found by the example above. If the o parameter of the JSONRequest function is not specified, then the function is GETRequest function.

jczic commented 1 year ago

Hello @iBigDane, Yes, without JSON content, it is a GET instead of a POST (content length of zero and no json content type). However, a JSON response to the request (GET or POST) will in all cases be expected and translated into a python object. Doesn't that make sense to you?

iBigDane commented 1 year ago

Hello @iBigDane, Yes, without JSON content, it is a GET instead of a POST (content length of zero and no json content type). However, a JSON response to the request (GET or POST) will in all cases be expected and translated into a python object. Doesn't that make sense to you?

Thanks, I see