1

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

PrashantK
  • 11
  • 4

2 Answers2

1

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
Dash
  • 1,191
  • 7
  • 19
0

Use request package like

import requests
        r = requests.post('/xyz/api/pqr/', params=Params)
lat long
  • 920
  • 6
  • 16
  • Thank for your prompt response. I tried this but it did not work. `code` #params = (name) #params = name params = ('name',name) response = requests.post(self.hostname + '/xyz/api/pqr/', auth=HttpNtlmAuth(self.username, self.password), headers=self.headers, params=params) – PrashantK Jul 02 '20 at 16:29