Skip to main content

Hi,


I am able to run aggregate code perfectly for aggregate call with

resp = platform.post('/analytics/calls/v1/accounts/~/aggregate/fetch',options),


but i am getting 'Unable to Authenticate : HTTP 400 error . when i use

resp = platform.post('/analytics/calls/v1/accounts/~/timeline/fetch',options)

Why ? Can anyone suggest what is wrong with this url ?



from ringcentral import SDK

import os,sys,json

from dotenv import load_dotenv

load_dotenv()

import pandas as pd




rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),

os.environ.get('RC_CLIENT_SECRET'),

os.environ.get('RC_SERVER_URL') )

platform = rcsdk.platform()


try:

# print(os.environ.get('RC_SERVER_URL') )

platform.login(os.environ.get('RC_USERNAME'),

os.environ.get('RC_EXTENSION'),

os.environ.get('RC_PASSWORD'))


options = {

"grouping": {

"groupBy": "Users",

"keys": []

},

"timeSettings": {

"timeZone": "US/Pacific",

"timeRange": {

"timeFrom": "2023-01-01T00:00:00.877Z",

"timeTo": "2023-04-01T04:01:33.877Z"

},

"advancedTimeSettings": {

"includeDays": [

"Sunday"

],

"includeHours": [

{

"from": "00:00",

"to": "23:59"

}

]

}

}

}





resp = platform.post('/analytics/calls/v1/accounts/~/timeline/fetch',options)

jsonObj = resp.json_dict()

It seems you missed providing the query params. Try to fix this like this

resp = platform.post('/analytics/calls/v1/accounts/~/timeline/fetch?interval=Week', options)

Also you can remove the 'key': [] if you don't specify any key in the array.


Hi,


I tried to add query param, but we still get the same error.

We can see API calls in Analytics with 400 error , which confirms our credentials are correct . Please check Screenshot (119).png


Your bodyParams (options) was missing some value. At least add 1 type of responseOptions* to the body. And next time, please format your code/data when posting to make it easy to read.

{
"grouping": {
"groupBy": "Users"
},
"timeSettings": {
"timeZone": "US/Pacific",
"timeRange": {
"timeFrom": "2023-01-01T00:00:00.877Z",
"timeTo": "2023-04-01T04:01:33.877Z"
},
"advancedTimeSettings": {
"includeDays": [
"Sunday"
],
"includeHours": [
{
"from": "00:00",
"to": "23:59"
}
]
}
},
"responseOptions": {
"counters": {
"allCalls": true
}
}
}

Reply