[Fixed]-When i was using PUT method in postman through Basic Auth i got an error ,i was working on django rest-framework

23👍

Its occure because of content type of your request .

  1. first check your views content type. 2.change content type according to view in postman .

For example :

Header -> add
key: “Content-Type”
value: “application/json”

6👍

Below the settings bar there is a "Content-Type" option try changing it to JSONenter image description here

0👍

def do(method ='get', data={}, is_json =True):
headers = {}
if is_json:
    headers['content-type'] ='application/json'
    data = json.dumps(data)
r = requests.request(method, ENDPOINT, data=data, headers = headers )
print(r.text)
print(r.status_code)
return r


do(method='post', data={"content": "some cool api ", 'user':1})

Leave a comment