Google calendar api 日历API活动参与者响应状态始终更改为;“需要行动”;
我正在做从salesforce到google日历api的调用,以插入google事件。当我发出请求时,它总是将与会者状态更改为“NeedsAction”,因此当我向google发送请求时,与会者状态为“已接受”,但作为响应,我得到了“NeedsAction”。为什么谷歌总是改变与会者的反应。如果有人知道,请帮忙。谢谢 请求机构:Google calendar api 日历API活动参与者响应状态始终更改为;“需要行动”;,google-calendar-api,Google Calendar Api,我正在做从salesforce到google日历api的调用,以插入google事件。当我发出请求时,它总是将与会者状态更改为“NeedsAction”,因此当我向google发送请求时,与会者状态为“已接受”,但作为响应,我得到了“NeedsAction”。为什么谷歌总是改变与会者的反应。如果有人知道,请帮忙。谢谢 请求机构: { "kind" : "calendar#event", "summary" : "nic
{
"kind" : "calendar#event",
"summary" : "nice 13 val",
"description" : "this is new",
"location" : "3 value friday",
"start" : {
"dateTime" : "2020-08-13T12:30:00+05:00"
},
"end" : {
"dateTime" : "2020-08-13T13:30:00+05:00"
},
"attendees" : [ {
"email" : "mohit.kumar@test.in",
"organizer" : true,
"responseStatus" : "accepted"
}, {
"email" : "test@gmail.com",
"responseStatus" : "accepted"
} ]
}
标注:
Http http = new Http();
HttpRequest httpReq = new HttpRequest();
httpReq.setEndpoint('https://www.googleapis.com/calendar/v3/calendars/mohit.kumar@test.in/events/'+objEvent.Google_Event_Id__c);
httpReq.setTimeout(30000);
httpReq.setHeader('Content-Type', 'application/json');
httpReq.setMethod('POST');
httpReq.setHeader('X-HTTP-Method-Override','PATCH');
httpReq.setHeader('Authorization', 'Bearer ' + accessToken);
String reqBody = createEventBody(objEvent, googleSettingInfo);
if (String.isNotBlank(reqBody)) {
httpReq.setBody(reqBody);
}
if (httpReq.getBody() != null && httpReq.getBody() != '') {
HttpResponse httpRes = http.send(httpReq);
System.debug('code: ' + httpRes.getStatusCode());
if (httpRes.getStatusCode() == 200) {
System.debug('response: ' + httpRes);
System.debug('create event response body: ' + httpRes.getBody());
}
}
获得与会者的响应始终是“需要行动”,而这应该是“接受的”test@gmail.com"
拟议修改:
如何修改createEventBody
函数以创建一个简单的JSON对象,该对象将只包含具有更新状态的Attendes
信息
这将正确地利用补丁语义,并有助于提高可读性
我自己测试过,生成的JSON对象在start
属性上返回一个错误。删除它也将帮助您解决该错误。最后,我测试了将attenders
属性传递给补丁方法是否可以正常工作
在实际更新代码之前,您可以尝试使用“trythisapi”功能
参考:
非常感谢@Alessandro,只留下与会者解决了我的问题。
{
"created": "2020-08-11T18:51:41.000Z",
"updated": "2020-08-28T06:48:49.972Z",
"summary": "nice 13 val",
"description": "this is new",
"location": "3 value friday",
"creator": {
"email": "mohit.kumar@test.in",
"self": true
},
"organizer": {
"email": "mohit.kumar@test.in",
"self": true
},
"start": {
"dateTime": "2020-08-13T14:00:00+05:30"
},
"end": {
"dateTime": "2020-08-13T15:00:00+05:30"
},
"sequence": 16,
"attendees": [
{
"email": "test@gmail.com",
"responseStatus": "needsAction"
},
{
"email": "mohit.kumar@test.in",
"organizer": true,
"self": true,
"responseStatus": "accepted"
}
],