Now Available - Forrester's Total Economic Impact study. Discover millions in cost savings, unlock IT efficiency gains, and explore why NIOS DDI is a game changer. Get Your Copy here.

API & Integration, DevOps,NetOps,SecOps


Post Method works for Postman but Python

New Member
Posts: 4
5634     0


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 = ""

payload = "{\"network\":\r\n\"func:nextavailablenetwork:,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=,auth=LOCAL,client=API,su=1,timeout=1800,mtime=1591971692,user=apiuser,apipassword"'

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


Re: Post Method works for Postman but Python

New Member
Posts: 4
5635     0

This method worked for me .


r = ,payload,
auth=("user", "password"),

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


Thank you.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You