日历 API - 使用日历 API v3 C# 库设置quotaUser 参数

发布于 2025-01-20 20:04:24 字数 1570 浏览 1 评论 0原文

我们的应用程序是使用域范围内委托执行请求对API进行日历。 直到某个时候,我们对此没有任何问题(我们在开发计算机中仍然没有问题),但是现在从我们的服务器上进行的请求需要几分钟的时间才能服务。我找到了通过设置 quotauser url参数。我们正在使用日历API V3 C#库,我们试图将Quotauser设置为任意字符串(请参见下面的代码)。不幸的是,这尚未解决问题。任何帮助将不胜感激。

var listOfUsersEmails = //someListOfEmails;
CalendarService service = GetCalendarService("credentials.json", gSuiteAdminEmail);
var events = new Events();
events.Items = new List<Event>();

var request = new BatchRequest(service);
foreach (var userEmail in listOfUsersEmails)
{
    var r = service.Events.List(userEmail);
    r.TimeMin = //today's beginning;
    r.TimeMax = //today's end
    r.ShowDeleted = false;
    r.SingleEvents = true;
    r.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
    
    // this is what we've tried
    r.QuotaUser = userEmail.Substring(0,40);
    // 

    request.Queue<Events>(
        r,
    (content, error, i, message) =>
    {
        if (content != null && content.Items != null)
        {
            foreach (var f in content.Items)
            {
                events.Items.Add(f);
            }
        }
    });
}
await request.ExecuteAsync();
return events;

这是@Daniel要求的屏幕截图(请参见下面的评论):

Our application is performing requests to Calendar API using domain-wide delegation.
We had no problem with that until sometime ago (and we still have no problem in our development computer), but now requests proceeding from our server are taking several minutes to be served, if at all. I’ve found this page explaining the problem and how to solve it by setting the quotaUser URL parameter. We’re using Calendar API v3 C# library and we’ve tried to simply set quotaUser to an arbitrary string (see code below). Unfortunately this has not solved the problem. Any help would be deeply appreciated.

var listOfUsersEmails = //someListOfEmails;
CalendarService service = GetCalendarService("credentials.json", gSuiteAdminEmail);
var events = new Events();
events.Items = new List<Event>();

var request = new BatchRequest(service);
foreach (var userEmail in listOfUsersEmails)
{
    var r = service.Events.List(userEmail);
    r.TimeMin = //today's beginning;
    r.TimeMax = //today's end
    r.ShowDeleted = false;
    r.SingleEvents = true;
    r.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
    
    // this is what we've tried
    r.QuotaUser = userEmail.Substring(0,40);
    // 

    request.Queue<Events>(
        r,
    (content, error, i, message) =>
    {
        if (content != null && content.Items != null)
        {
            foreach (var f in content.Items)
            {
                events.Items.Add(f);
            }
        }
    });
}
await request.ExecuteAsync();
return events;

Here is the screenshot that @Daniel asked for (see comments below):
GCP quotas for project

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文