David R. K. DeLoveh
David R. K. DeLoveh

Reputation: 11

What is the Microsoft GraphServiceClient v5 Replacement for AppendSegmentToUrl

While investigating an upgrade of my C# use of Microsoft GraphServiceClient v4 to v5 I was looking at the usage I have of the chats: getallMessages for which I need to be able to append the "model" query string parameter this format:

GET /users/{id | user-principal-name}/chats/getAllMessages?model=A

In v4 it would look like:

string userGuidString = ...
GraphServiceClient gsc = ...
var results = await new UserChatsCollectionRequestBuilder(
   gsc.Users[userGuidString].Chats.GetAllMessages().AppendSegmentToRequestUrl("?model=A")
   , gsc.Request().GetAsync();

Checking the MS upgrade guide I see only one mention of the AppendSegmentToRequestUrl which was only how to stop using it for the $count piece and use a built in method.

The best I can come up with for v5 is to deal with it myself by using the Uri class.

string userGuidString = ...
GraphServiceClient gsc = ...
var results = await new Microsoft.Graph.Users.Item.Chats.GetAllMessages.GetAllMessagesRequestBuilder(
   new Uri(gsc.Users[userGuidString].Chats.GetAllMessages.ToGetRequestInformation().URI, "?model=A").ToString()
   , gsc.RequestAdapter).GetAsync();

Sure this works, but since they didn't call out this issue in the upgrade guide it seems like I must be missing how to do this in the v5 syntax. Is there a way?

Upvotes: 1

Views: 414

Answers (0)

Related Questions