[英]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.