How to send an array using requests.post (Python)? “Value Error: Too many values to unpack”

前端 未结 4 1798
暖寄归人
暖寄归人 2020-12-13 01:52

I\'m trying to send an array(list) of requests to the WheniWork API using requests.post, and I keep getting one of two errors. When I send the list as a list, I get an unpac

4条回答
  •  萌比男神i
    2020-12-13 02:32

    Always remember when sending an array(list) or dictionary in the HTTP POST request, do use json argument in the post function and set its value to your array(list)/dictionary.

    In your case it will be like:

    r = requests.post(url, headers=headers, json=data)

    Note: POST requests implicitly convert parameter's content type for body to application/json.

    For a quick intro read API-Integration-In-Python

提交回复
热议问题