RESTful Soft Delete

You should use DELETE. What you intend to do with your data is called “soft deleting”: you set a flag and avoid flagged items from appearing. This is internal to your webapp and the user doesn’t have to know that you’re soft deleting instead of deleting or whatever you want to do. This is why … Read more

Django Test Client Method Override Header

You need to specify header as ‘HTTP_X_HTTP_METHOD_OVERRIDE’ instead of ‘X_HTTP_METHOD_OVERRIDE’ i.e. add HTTP_ at the beginning of the header. header = {‘HTTP_X_HTTP_METHOD_OVERRIDE’: ‘PUT’} response = client.post(‘/model/1/’, content_type=”application/json”, data=post_data_clean, **header) From the Django documentation: HTTP headers in the request are converted to META keys by converting all characters to uppercase, replacing any hyphens with underscores and … Read more

How to specify python requests http put body?

Quoting from the docs data – (optional) Dictionary or bytes to send in the body of the Request. So this should work (not tested): filepath=”yourfilename.txt” with open(filepath) as fh: mydata = fh.read() response = requests.put(‘https://api.elasticemail.com/attachments/upload’, data=mydata, auth=(‘omer’, ‘b01ad0ce’), headers={‘content-type’:’text/plain’}, params={‘file’: filepath} )