kotlin - Google Calendar API v3 未保存活动地点和与会者
问题描述
我正在测试Google Calendar API v3,唯一缺少的字段是location
获取attendees
日历事件。我正在使用 REST 接口(google oauth2 和我登录的用户是日历所有者),我可以进行所有所需的 CRUD 操作,但由于某种原因,location
被attendees
忽略了。如果我在Google API Explorer或 Postman中使用相同的有效负载(从控制台输出复制),它可以工作......我错过了什么?
示例播放负载:
POST https://www.googleapis.com/calendar/v3/calendars/[YOUR_CALENDAR_ID]/events?key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"end": {
"timeZone": "Europe/Lisbon",
"dateTime": "2021-05-13T10:00:00+01:00"
},
"start": {
"timeZone": "Europe/Lisbon",
"dateTime": "2021-05-13T08:00:00+01:00"
},
"attendees": [
{
"email": "batman@mail.com"
}
],
"location": "Batcave"
}
我正在使用 Ktor,这是代码:
client.post<Event>("https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events") {
body = event
parameter(API_KEY_PARAMETER, apiKey)
contentType(ContentType.Application.Json)
header(HttpHeaders.Authorization, token)
}
其中事件:
@Serializable
data class Event(
val id: String = "",
val status: String = "",
val created: String = "",
val updated: String = "",
val creator: Attendee,
val start: DateLabel,
val end: DateLabel,
val summary: String = "",
val description: String = "",
val location: String = "",
val attendees: List<Attendee> = emptyList(),
val maxAttendees: Int = 5
)
@Serializable
data class DateLabel(
val date: String = "",
val dateTime: String = "",
val timeZone: String = ""
)
@Serializable
data class Attendee(val email: String)
解决方案
推荐阅读
- reactjs - reactjs中同名复选框如何将值保留为数组
- python - 在读取 BigQuery 数据集 python SDK 的数据流中指定区域
- regex - 如何配置 nginx.ingress.kubernetes.io/rewrite-target 和 spec.rules.http.paths.path 以满足以下 URI 模式
- excel - 如何创建一个对任意数量的行进行小计并将总计放在正确的行中的宏?
- angularjs - 在angularJS中使用recaptcha
- asp.net - 在实体框架中,如何在 Select 子句中使用聚合函数?
- swift - 接近传感器黑屏
- amazon-web-services - DynamoDb 将项目保留特定时间
- three.js - Three.js:带有 OrbitControls 的 Pepper 鬼影效果:相机平移/旋转问题
- excel - 如何从一张 Excel 表格剪切/粘贴行到另一张表格的第一个空白行