Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Reply

Post Method works for Postman but Python

New Member
Posts: 4
6078     0

Hello,

I coud achieve post requests via Postman when i try in python code which gives below error. I read its because of  role, i added new user with api permission  , even previous user works with Postman but didnt work.

 

b'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>401 Authorization Required</title>\n</head><body>\n<h1>Authorization Required</h1>\n<p>This server could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn\'t understand how to supply\nthe credentials required.</p>\n</body></html>\n'

 

My Code:

import requests

url = "https://10.10.10.10/wapi/v2.7/network"

payload = "{\"network\":\r\n\"func:nextavailablenetwork:10.10.8.0/21,default,28\",\r\n\"comment\":\"Test\",\r\n\"network_view\":\"default\"\r\n}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'ibapauth="group=admin-group,ctime=1591971023,ip=10.10.10.2,auth=LOCAL,client=API,su=1,timeout=1800,mtime=1591971692,user=apiuser,apipassword"'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

Re: Post Method works for Postman but Python

New Member
Posts: 4
6078     0

This method worked for me .

 

r = requests.post(url ,payload,
auth=("user", "password"),
verify=False)

 After that  i should contione with cookie (r.cookies).

 

Thank you.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You