Need to call POST method of REST API

api

#1

I am trying like this - I have a rest API and using post method to call this API.
First I am trying to have authentication and later the body and the URL.

import requests
import json
from requests.auth import HTTPBasicAuth
requests.get(‘url’, auth=HTTPBasicAuth(‘username’, ‘pass’))

payload = {‘name’:‘rest_python’,‘domainId’:‘7319ca59-f9d4-4f86-9eaf-a359691b378b’,‘typeId’:‘00000000-0000-0000-0000-000000011001’}
response = requests.post(url, data=payload)

print(response.text) #TEXT/HTML
print(response.status_code)

it says
401

what would be the issue here.

Thanks,
Sachin


#2

HI, Can you please tell me How you write Post Method in View.py file?