PrashantK
PrashantK

Reputation: 11

How to pass parameter to POST request in python

Folks,

I am new to python and working on REST API in python. I am facing issue in below scenario where I don't understand how to pass the parameter.

Request URL:URL/xyz/api/pqr/
Request method:POST
Params - "test"
Response - {"apps":[], ...., "users": []}

I tried standard ways of passing parameter in json and directly to URL but did not work.

edit - I was searching on this and came across this URL - Parameter Binding in Web API

Following is a valid HTTP POST request in the fiddler for the above action method.

enter image description here

It is for .net platform but I don't see same option in python. Is there any way we can do it in python?

Thanks, Prashant

Upvotes: 1

Views: 1727

Answers (2)

lat long
lat long

Reputation: 930

Use request package like

import requests
        r = requests.post('/xyz/api/pqr/', params=Params)

Upvotes: 0

Dash
Dash

Reputation: 1299

Take a look at the requests package.

You could do something like:

import requests

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

print(r.text)   # The response

Upvotes: 1

Related Questions