Aug-08-2019, 08:51 AM
Hi All,
Below is my requirement and below is my code.
When we post the request to some API via API calls a cookie session will be created on each API call and all the sessions ID, tokens are unique each time. XSRF token is to establish the session with the particular URL for further working sessions with it. The requirement is we just need only to extract the XSRF token from the output
Below is my requirement and below is my code.
When we post the request to some API via API calls a cookie session will be created on each API call and all the sessions ID, tokens are unique each time. XSRF token is to establish the session with the particular URL for further working sessions with it. The requirement is we just need only to extract the XSRF token from the output
import requests import json import os HOST = 'https://console.cloudendure.com/api/v5/login' #api_token = '4bbe1c1c-4c67-4603-886b-9d842ccef12a' headers = { 'userApitoken' : '4bbe1c1c-4c67-4603-886b-9d842ccef12a' } endpoint = '/api/v5/' session = requests.Session() session.headers.update({'Content-type': 'application/json', 'Accept': 'text/plain'}) resp = session.post(url=HOST, data=json.dumps({'username': '[email protected]', 'password': 'Password123'})) response = resp.cookies print(response)