I need to add a header to a request in a Django test. I have browsed a few pages on both Stack Overflow and elsewhere, following various suggestions. I can add the headers to PUTs and GETs successfully, but having an issue with POSTs. Any advice would be greatly appreciated.
For PUT and GET I have used the following [passing successfully]:
resp = self.client.put(resource_url, res_params, **{'HTTP_SSL_CLIENT_CERT': self.client_cert})
For POST, I tried the same thing but am receiving the error: "'str' object has no attribute 'items'"
I have tried the following:
resp = self.client.post(resource_url, res_params, **{'HTTP_SSL_CLIENT_CERT': self.client_cert})
resp = self.client.post(resource_url, res_params, HTTP_SSL_CLIENT_CERT=self.client_cert)
resp = self.client.post(resource_url, res_params, HTTP_SSL_CLIENT_CERT='1234567890')
For anybody that finds themselves looking at this page with a similar issue, I was able to get this working with the following:
resp = self.client.post(resource_url, data=res_params, content_type='application/json', HTTP_SSL_CLIENT_CERT=self.client_cert)