Issue in Fetching Historical Data

constatntly getting Error: 400
{“errorType”:“Input_Exception”,“errorCode”:“DH-905”,“errorMessage”:“Missing required fields, bad values for parameters etc.”}

Python file below :

import requests
import json

Define the API endpoint and headers

url = “https://api.dhan.co/v2/charts/historical
headers = {
“Content-Type”: “application/json”,
“access-token”: “My acees token”
}

Define the data to send in the request

data = {
“symbol”: “TCS”,
“exchangeSegment”: “NSE_EQ”,
“instrument”: “EQUITY”,
“expiryCode”: 0,
“fromDate”: “2025-04-25”,
“toDate”: “2025-04-25”
}

Send the POST request

response = requests.post(url, headers=headers, json=data)

Check the response status and print the result

if response.status_code == 200:
print(json.dumps(response.json(), indent=4)) # Print the response in a readable format
else:
print(f"Error: {response.status_code}")
print(response.text)