[Fixed]-Finding JSON POST format of an API

1👍

In[2]: import json
In[3]: data = dict(data="[1,3]")
In[4]: data
Out[4]: {'data': '[1,3]'}
In[5]: json.dumps(data)
Out[5]: '{"data": "[1,3]"}'

json.dumps(data) returns string.

From requests doc

:param data: (optional) Dictionary, bytes, or file-like object to send
in the body of the :class:Request.

So API you use handle correctly post request with json:

{"data": "[list of ints]"}
#e.g.
{"data": "[2,3,4,5]"}

and that’s you can figure out the third party.

👤KePe

Leave a comment