@Phanilbb said in What is the issue with this request.. I'm getting Invalid Token error:
I have not changed but tried different
import requests
def get_profile(angel_one_details, jwt_token):
RuntimeError: If the API request fails with a non-200 status code
"https://apiconnect.angelbroking.com/rest/secure/angelbroking/user/v1"
profile_endpoint = "getProfile"
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-UserType': 'USER',
'X-SourceID': 'WEB',
'X-PrivateKey': angel_one_details['api_key'],
'Authorization': f"Bearer {jwt_token}" }
url = f"{base_url}/{profile_endpoint}"
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise RuntimeError(f"API request failed with status code: {response.status_code}")
I hope it