简体   繁体   English

使用 C# Office Graph SDK 客户端指定请求标头

[英]Specifying request headers using C# Office Graph SDK client

I am interacting with Office graph using C# Office Graph SDK.我正在使用 C# Office Graph SDK 与 Office 图形交互。 I need to create specific request header, while I am using GraphServiceClient and RequestBuilder to create the request.我需要创建特定的请求标头,同时我使用 GraphServiceClient 和 RequestBuilder 创建请求。 How can I achieve that?我怎样才能做到这一点?

To set custom header for the request, you need to create Option collection.要为请求设置自定义标头,您需要创建 Option 集合。 To add headers, you need to add new item of type HeaderOption to this collection.要添加标题,您需要向该集合添加 HeaderOption 类型的新项目。 See code sample bellow:请参阅下面的代码示例:

List<Option> options = new List<Option>
{
   //Creating query parameters
   new QueryOption("filter", $"(start/dateTime le '{DateTime.Now.AddMinutes(5).ToString("yyyy-MM-ddTHH:mm")}')),

   //Creating header
   new HeaderOption("Prefer","outlook.timezone=\"Europe/Budapest\"")
};

var res = await graphClient.Users["userId"].Events.Request(options).GetAsync();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# 带有 Office 365 和图形客户端的邮件 - C# Mail with Office 365 And Graph Client 如何使用C#Graph SDK批量删除Office365中的事件 - How to batch delete events in Office365 using C# Graph SDK 从 Beta Graph Api 获取响应头 使用 C# SDK 调用 - Getting response headers from Beta Graph Api Call using C# SDK 使用 c# 客户端缺少授权标头 - Authorization Headers is missing using c# client c# 使用 httpparams 和 headers 发布请求 - c# post request using httpparams and headers 使用 c# http 客户端时,请求标头必须仅包含 ASCII 字符吗? - Request headers must contain only ASCII characters while using c# http client? Facebook C# SDK 在对 FB Graph Api 的单个请求(调用)中使用多个 id - Facebook C# SDK using multiple id´s in a single request (call) to FB Graph Api 为Elastic Search指定和使用带有C#NEST客户端的NGramTokenizer - Specifying and using a NGramTokenizer with the C# NEST client for Elastic Search 在C#Web服务客户端中指定故障转移服务器 - Specifying failover servers in c# webservice client 没有Open Office SDK和Microsoft Office Interop的C#PowerPoint - C# PowerPoint without Open Office SDK and Microsoft Office Interop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM