Is it possible to set a RingCentral user's timezone through the API?

倖福魔咒の 提交于 2021-01-29 08:52:25

问题


I was looking thru the API for how to set timezone and cannot find it. Is there not a way to set the timezone thru the API?


回答1:


A user's timezone is set as part of their extension properties and is read using the Extension Info API and set via the Update Extension Info endpoint, not a specific timezone endpoint. I'll start with the read because the response provides an easy way to create the update timezone request.

Read Timezone

To read the user's current timezone, retrieve the user's settings info using the following endpoint. You will get a lot of properties. From the response, you can see how to create the update request.

GET /restapi/v1.0/account/{accountId}/extension/{extensionId}

The response will contain a lot of information including the timezone as shown. Use this JSON path in your update request with a timezone id shown later below.

{
    "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222",
    "id": 22222222,
    "extensionNumber": "101",
    ...
    "regionalSettings": {
        "timezone": {
            "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/timezone/60",
            "id": "60",
            "name": "Pacific/Honolulu",
            "description": "Hawaii",
            "bias": "-600"
        },...
    }
}

See more in the API Reference:

https://developer.ringcentral.com/api-reference#User-Settings-loadExtensionInfo

Set Timezone

To set a user's timezone, update the user's extension endpoint using the PUT method and specify the timezone id in the body as shown. The timezone ids can be found in the timezone endpoint shown next.

PUT /restapi/v1.0/account/{accountId}/extension/{extensionId}

{
    "regionalSettings": {
        "timezone": {
            "id": "58"
        }
    }
}

https://developer.ringcentral.com/api-reference#User-Settings-updateExtension

List Timezones

To get a list of timezones, call the timezone endpoint:

GET /restapi/v1.0/dictionary/timezone

The response provides a list of timezones with description and a timezone id that is used in the update user settings request.

{
    "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/timezone?page=1&perPage=100",
    "records": [
        {
            "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/timezone/1",
            "id": "1",
            "name": "GMT",
            "description": "Casablanca, Monrovia, Reykjavik",
            "bias": "0"
        },
        {
            "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/timezone/2",
            "id": "2",
            "name": "Europe/Lisbon",
            "description": "Dublin, Edinburgh, Lisbon, London",
            "bias": "0"
        },
        ...
        {
            "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/timezone/91",
            "id": "91",
            "name": "Asia/Pyongyang",
            "description": "Pyongyang",
            "bias": "510"
        }
    ],
    "paging": {...},
    "navigation": {...}
}

See the API Reference for more information:

https://developer.ringcentral.com/api-reference#Regional-Settings-listTimezones



来源:https://stackoverflow.com/questions/51681789/is-it-possible-to-set-a-ringcentral-users-timezone-through-the-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!