Home > Net >  Status code 200 without response on the server
Status code 200 without response on the server

Time:08-25

When I make a PUT with a JSON and I receive status code 200 but there is no response on the server shown. When I am making a PUT from Postman, everything is fine so, I think that the problem might be in my header:

Boxes = [{'X': 2423, 'Y': 532, 'W': 7456, 'H': 2345}]
res = json.dumps(Boxes)

r = requests.put(
"http://127.0.0.1:8000/snippets/1/",
data=json.dumps({"Boxes": res,
                 "Amount": '234'
                 }),
headers={'Authorization': 'Token a50ad9e5ff215abd67028a8bd904a11ac0b1409f',
         'Content-Type': 'application/x-www-form-urlencoded',
         'Vary': 'Accept',
         'Allow': 'GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS',
         'X-Frame-Options': 'DENY',
         'Content-Length': '140',
         'X-Content-Type-Options': 'nosniff',
         'Referrer-Policy': 'same-origin',
         'Cross-Origin-Opener-Policy': 'same-origin'},)
print(r.status_code)

Headers in Postman: enter image description here

Any suggestions on why that might be?

CodePudding user response:

In my case, I solved the issue by changing authentication details. I managed to make a request via basic auth:

username = ...
password = ... 
response = request.put(url, auth = (username, password) 

However, I am not sure why this solved the issue

  • Related