我正在尝试通过 Microsoft Graph API 更新计划详细信息。我的项目是 MVC .Net 4。GET 和 POST 请求很好,但是当我尝试更新计划的详细信息时,请求中的 IF-Match 标头是强制性的,所以我在 if-match 部分发送 ETAG 值但一直说IF-Match Value 无效,有时说引用错误。帮我。
这些是我按照以下请求的顺序构建后的一些响应 1)/Home/EditPlanAction 中的错误:值 'W/\"JzEtUGxhbiAgQEBAQEBAQEBAQEBAQEBATCc=\"' 的格式无效。
2 & 3) 错误 in/Home/EditPlanAction: { "error": { "code": "", "message": "The If-Match header contains an invalid value.", "innerError": { "request-id ": "e7744797-f0ac-45c6-a1a6-73dcd3838759", "日期": "2019-05-03T21:03:24" } } }
if (method != HttpMethod.Get && method != HttpMethod.Delete && method !=
HttpMethod.Post && method != HttpMethod.Put)
{
string uri1 = uri.Replace("/details", "");
HttpResponseMessage foretag = await
ServiceHelper.SendRequest(HttpMethod.Get, $"{graphV1Endpoint}{uri1}",
accessToken);
//EntityTagHeaderValue entityTagHeaderValue = new
EntityTagHeaderValue((foretag.Headers.ETag.Tag));
//JsonConvert.SerializeObject(entityTagHeaderValue, jsonSettings);
string etag1 = foretag.Headers.ETag.Tag;
string etag2 = etag1.Replace("\"", "");
//string etag3 = "W/\\\"" + etag2 + "\\\"";
`request.Headers.Add("If-Match", "W/\\\"" + etag2 + "\\\"");`
`request.Headers.Add("If-Match", "W/\"" + etag2 + "\"");`
`request.Headers.Add("If-Match", "\"" + etag2 + "\"");`
`request.Headers.Add("If-Match", "\\\"" + etag2 + "\\\"");`
`request.Headers.Add("If-Match", etag2 );`