I'm using python request to connect to grafana datasource api- error: Max retries exceeded with url: /api/datasources

I’m using Grafana 9 version, that is running on amazon linux 2 server.
My goal is to automate data source creation using python script.
For this, I’m using /api/datasources
So basically, using python requests library, trying a POST api request.
Below is just a small part of my python script.

import requests

url_query = ‘https:///api/datasources’

head = {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Bearer ’
}

params = {
“name”: “cloudwatch_test9”,
“type”: “cloudwatch”,
“access”: “proxy”,
“jsonData”: {
“authType”: “keys”,
“defaultRegion”: “us-west-1”
},
“secureJsonData”: {
“accessKey”: “”,
“secretKey”: “”
}
}

x = requests.post(url_query, headers=head, json=params)
print(x.text)

This code created the datasource most of the time, but I also get below error occasionally: Max retries exceeded with url: /api/datasources

I’m new to automation, let me know if any suggestions.