POST API Request using API Key and Value throwing error

I am trying to execute the below script using but the connection is not getting established. When executed using postman, the request got succeded. There is some issue with the authorisation part. Can someone please help.

import requests

api_key = "lj2xxxx"
api_value = "awR7Gxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxk"

# Set up the headers with the API key and value
headers = {
"Content-Type": "application/json",
"X-Api-Key": api_key,
"X-Api-Value": api_value
}

# data
data = {
"data": {
"type": "queueHistoryTimeSeries",
"id": 1,
"attributes": {
"queueTimeSeries": {
"dataSourceName": "AZ_Services_Datasource",
"queueName": "AZS_Test2",
"time": "2023-01-07T08:00:00.000-0700",
"reportInterval": 30,
"dataSourceGroupTimeSeries": [
{
"dataSourceGroupName": "TestG2",
"volumeActual": 80,
"volumeHandledActual": 90,
"averageSpeedToAnswerActual": 90,
"activityHandlingTimeActual": 120,
"serviceLevelActual": 50,
"abandonsActual": 90,
"backlogActual": 90,
"occupancyActual": 90,
"staffingActual": 90
}
]
}
}
}
}

# Set up the endpoint URL
url = "">xxxxxxxxxx/.../timeSeriesData"

# Send a POST request to the endpoint with the headers
response = requests.post(url, headers=headers,data=data)
print(response.request.url)
print(response.request.headers)
print(response.request.body)

# Print the response content
#print(response.content)

if response.status_code == 200:
print('Data successfully posted to Verint CSI API')
else:
print(f'Error posting data to Verint CSI API: {response.status_code}')

Parents Reply Children
No Data