I want to do a post request in python with basic authentication AND token. I have already tested the post in postman and it worked but with python I always get status code 403.
For this API I have to do...
- first fetch a token from the header with a GET request
- use this token in header for POST request
auth = HTTPBasicAuth('User', 'Password')
token = requests.get(URL_token, auth=auth, headers={"x-csrf-token":"FETCH"}).headers['x-csrf-token']
requests.post(POST_url, data=json.dumps(test_data), headers={"x-csrf-token":token}, auth=auth)
The test_data are type of a list and again, in postman it works.
Is there something which I am doing wrong in the POST?