question

Arshaq Meraj avatar image
Arshaq Meraj asked Phong Vu commented

HTTP 400 Error for timeline API call

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()

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

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.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Arshaq Meraj avatar image
Arshaq Meraj answered

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


screenshot-119.png (126.9 KiB)
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered Phong Vu commented

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
     }
  }
}
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Arshaq Meraj avatar image Arshaq Meraj commented ·

Thanks for you reply.

I added responseOptions to params just like you suggested, but still getting the same error HTTP 400.

Can you please confirm there is no issue at the backend. Why do i see calls in API call log in sandbox? I am not using sandbox credentials. Please check both screenshots. Screenshot (120).pngScreenshot (121).png

My credentials for production is being used for these API calls. So i should see API call log in production and not in sandbox . Do you think there is some problem there with the app ?


0 Likes 0 ·
screenshot-120.png (56.8 KiB)
screenshot-121.png (58.7 KiB)
Phong Vu avatar image Phong Vu ♦♦ Arshaq Meraj commented ·

That's pretty much the minimum query and body parameters you need to call the timeline analytics API.

I cannot run test on your production account. So submit a dev support ticket and someone can have a look at your account to help.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys