简体   繁体   中英

Add description to Office365 Planner task throug Grap API

I'm trying to add a description to an Office365 Planner task via Grap API.

The necessary HttpRequest requires a "If-Match" entry in its headers with an Etag value. I get the Etag from a former request to the task details. The Etag I get looks like this:

"@odata.etag": "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBASCc=\""

As you can see, there are two \\" within this Etag string which cause some troubles.

In my code I've tried the following three ways to create a "If-Match" header without succes:

1. request.Headers.IfMatch.Add(new EntityTagHeaderValue(etag));
2. request.Headers.IfMatch.Add(EntityTagHeaderValue.Parse(etag));
3. request.Headers.TryAddWithoutValidation("If-Match", etag);

Line 1. causes an exception, because of the " within the string. Line 2. and 3. lead to a "not found" response of the request, because the \\ character is missing in the Etag. The VS debugger shows the following content of the IfMatch property:

"W/"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBASCc=""

Thanks for help.

Ok, problem solved.

The Etag was not the reason for the non working update request. The received error was misleading.

Needed to use HttpMethod "PATCH" instead of "POST".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM