Avi
Avi

Reputation: 1633

HTTP 405 when making a Python PUT request

I have a requirement to make a PUT request from Python and I have been getting a HTTP 405 response code consistently. Any pointers to the code below would be great.

filepath = './sdfdd/sdfdsst/xxxxxxxxxrrrarara.json'
with open(filepath) as fh:
mydata = fh.read()
response = requests.put('https://asdfs.sdf.sdfds.com',
  data=mydata,                         
  auth=('Authorization', 'Api-Token dsdfdsfsdfsdf'),
  headers={'content-type':'application/json'},
  params={'file': filepath},
  allow_redirects=True
)
print(response)

Upvotes: 0

Views: 117

Answers (1)

Avi
Avi

Reputation: 1633

It was due to incorrect API endpoint which was causing this issue.

Upvotes: 1

Related Questions