get "{'code': -1002, 'msg': 'You are not authorized to execute this request.'}" while trying to fetch withdrawal fees

I’m trying to get withdrawal fees but get this error. This is my code:
import requests

Your Binance API Key and Secret (keep these secure)

api_key = ‘’ # here i put my api_key

Binance API endpoint for asset configuration

url = ‘https://api.binance.com/sapi/v1/capital/config/getall

Set up headers with API Key

headers = {
‘X-MBX-APIKEY’: api_key
}

Send a GET request to the endpoint with headers

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

data prints {‘code’: -1002, ‘msg’: ‘You are not authorized to execute this request.’}. What am I doing wrong? Also, is there another way to get withdrawal fees?

I had the same problem and solved it.

The error code -1002 with the message “You do not have permission to execute this request” usually indicates an issue with your API key or permissions. Make sure your API key is entered correctly and has the necessary permissions.