How to make a post request with the Python requests library?

前端 未结 4 1607
别跟我提以往
别跟我提以往 2020-12-29 12:12

I am using the following filters in Postman to make a POST request in a Web API but I am unable to make a simple POST request in Python with the requests library.

<

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-29 12:19

    You are sending user in url, use it through post, but its depend upon how end points are implemented. You can try the below code :

    import requests
    from json import dumps
    
    data = {'user_name':'user&001'}
    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
    url = "http://10.61.202.98:8081/T/a/api/rows/cat/ect/tickets/"
    r = requests.post(url, headers=headers, data=dumps(data))
    

提交回复
热议问题