Closed andrueastman closed 1 year ago
Will this be able to run on net6.0-maccatalyst
or generally speaking be usable with MAUI? This compatibility issue is around for quite some time now, but none of the open issues were given any kind of feedback. Any info would be greatly appreciated - please see issues #1329 and #413
How would I serialize a chat message to json?
It seems to serialize additional data wrong:
"From": { "AdditionalData": {}, "Application": null, "BackingStore": { "InitializationCompleted": true, "ReturnOnlyChangedValues": false }, "Device": null, "User": { "AdditionalData": { "userIdentityType": "aadUser" }, "BackingStore": { "InitializationCompleted": true, "ReturnOnlyChangedValues": false }, "DisplayName": "theUser", "Id": "TheUSersGuid" }
Are any any buildin/preconfigured serializers that do this well?
the user is to be serialized like this:
"user": { "displayName": "Some User", "id": "UserId", "userIdentityType": "aadUser" }
Recommendation for upgrade docs:
how can we do that with SDK v5.0.0 ?
var driveItem = new DriveItem
{
Name = path,
Folder = new Folder(),
AdditionalData = new Dictionary<string, object>() { { "@microsoft.graph.conflictBehavior", "fail" } }
};
await graphClient.Sites[siteId].Drives[driveId].Root.Children.Request().AddAsync(driveItem);
How would I serialize a chat message to json?
It seems to serialize additional data wrong:
"From": { "AdditionalData": {}, "Application": null, "BackingStore": { "InitializationCompleted": true, "ReturnOnlyChangedValues": false }, "Device": null, "User": { "AdditionalData": { "userIdentityType": "aadUser" }, "BackingStore": { "InitializationCompleted": true, "ReturnOnlyChangedValues": false }, "DisplayName": "theUser", "Id": "TheUSersGuid" }
Are any any buildin/preconfigured serializers that do this well?
the user is to be serialized like this:
"user": { "displayName": "Some User", "id": "UserId", "userIdentityType": "aadUser" }
You can access the inbuilt serializer as below to perform the serialization for you @ymoona
var seralizer = graphServiceClient.RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
seralizer.WriteObjectValue(string.Empty,application);
var serializedContent = seralizer.GetSerializedContent();
how can we do that with SDK v5.0.0 ?
var driveItem = new DriveItem { Name = path, Folder = new Folder(), AdditionalData = new Dictionary<string, object>() { { "@microsoft.graph.conflictBehavior", "fail" } } }; await graphClient.Sites[siteId].Drives[driveId].Root.Children.Request().AddAsync(driveItem);
Tracked via https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1524
I am sure this is a stupid question, but I can't figure out how to get a DriveItem by path.
What is funny is the documentation has examples in c# for most things except for getting it by path, for that it only shows the HTTP option: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-beta&tabs=http#examples
I have tried graphClient.Drive.Items[Path].GetAsync()
and graphClient.Drive.Root.Children[Path].GetAsync()
all of which fail. i can see the official request should be root:/{item-path}
but I don't know how to do that in c#. There is no Root object this handler so you can't do Root[Path]
I could maybe abuse the Root.GetAsync() and add a header to the path but that seems wrong.
I do realize it sounds similar to #1524 but that sounded like the issue was the lack of a Post handler and the example was for adding.
I am sure this is a stupid question, but I can't figure out how to get a DriveItem by path.
What is funny is the documentation has examples in c# for most things except for getting it by path, for that it only shows the HTTP option: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-beta&tabs=http#examples
I have tried
graphClient.Drive.Items[Path].GetAsync()
andgraphClient.Drive.Root.Children[Path].GetAsync()
all of which fail. i can see the official request should beroot:/{item-path}
but I don't know how to do that in c#. There is no Root object this handler so you can't doRoot[Path]
I could maybe abuse the Root.GetAsync() and add a header to the path but that seems wrong.
I do realize it sounds similar to #1524 but that sounded like the issue was the lack of a Post handler and the example was for adding.
I am also experiencing same issue.
graphClient.Me.Drive
and graph.Users["userId"].Drive
does not contain field Items
.
@adamijak I found most of the old Me. endpoints should now be accessed without the Me. Me.Drive is more of a request to get the users root drive metadata. So you can do graphClient.Drive.Items["id"] where before you were doing Me.Items. The problem I have is the API is auto generated so paths like Drive.Items get directly translated into /drive/items for requests. I can't figure out how to do a root:/item-path query though.
I am sure this is a stupid question, but I can't figure out how to get a DriveItem by path.
What is funny is the documentation has examples in c# for most things except for getting it by path, for that it only shows the HTTP option: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-beta&tabs=http#examples
I have tried
graphClient.Drive.Items[Path].GetAsync()
andgraphClient.Drive.Root.Children[Path].GetAsync()
all of which fail. i can see the official request should beroot:/{item-path}
but I don't know how to do that in c#. There is no Root object this handler so you can't doRoot[Path]
I could maybe abuse the Root.GetAsync() and add a header to the path but that seems wrong.
I do realize it sounds similar to #1524 but that sounded like the issue was the lack of a Post handler and the example was for adding.
It should be possible to do the following with the latest previews.
var item = await graphServiceClient.Drives["drive-id"].Items["item-id"]
.ItemWithPath(Path.GetFileName("data/sample.pdf"))
.Content
.GetAsync();
var item2 = await graphServiceClient.Drives["ils"].Root
.ItemWithPath(Path.GetFileName("sample.pdf"))
.Content
.GetAsync();
More information on the drive paths is documented at the link below.
Let's assume that I have the following code for v4
client.Users[userId].CalendarView.Request(queryOptions).Filter(filterQuery).Expand(expandOptions).Select(SelectQuery).GetAsync()
The code for v5 looks like this but there is no Expand property in CalendarViewRequestBuilderGetQueryParameters
class
client
.Users[userId]
.CalendarView
.GetAsync(cfg =>
{
cfg.QueryParameters.StartDateTime = from;
cfg.QueryParameters.EndDateTime = to;
cfg.QueryParameters.Filter = filterQuery;
cfg.QueryParameters.Select = SelectQuery;
})
Is it a bug or is there any other reason why Expand property is missing in CalendarViewRequestBuilderGetQueryParameters
?
Greetings,
I am receiving the error message "Microsoft.Graph.Models.ODataErrors.ODataError: 'Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown.'" leveraging .NET MAUI 7.0 with Microsoft.Graph to execute WindowsAutoPilotDeviceIdentity.UpdateDeviceProperties. I submitted the below to stackoverflow when running 5.0.0 preview 14, though, I am still getting the same error after the update to 5.0.0-rc.1. Is there an issue with my code, or is this not supported with maui?
Stackoverflow question URL: https://stackoverflow.com/questions/74816802/how-do-i-leverage-microsoft-graph-to-update-autopilot-information
public async Task<bool> UpdateAutopilotDeviceAsync(string managedDeviceId, UpdateDevicePropertiesPostRequestBody updateParameters)
{
if (_graphServiceClient == null)
{
await SignInAndInitializeGraphServiceClient();
}
try
{
//LINE THROWING ERROR HERE
await _graphServiceClient.DeviceManagement.WindowsAutopilotDeviceIdentities[managedDeviceId].UpdateDeviceProperties.PostAsync(updateParameters);
//LINE THROWING ERROR HERE
return await Task.FromResult(true);
}
catch { }
private async void Save_Clicked(object sender, EventArgs e)
{
string managedDeviceId = Device.ManagedDeviceId;
UpdateDevicePropertiesPostRequestBody updateParameters = new()
{
UserPrincipalName = Device.UserPrincipalName,
AddressableUserName = Device.AddressableUserName,
GroupTag = Device.GroupTag,
DisplayName = Device.DisplayName
};
await PublicClientSingleton.Instance.MSGraphHelper.UpdateAutopilotDeviceAsync(managedDeviceId, updateParameters);
}
Stack trace:
0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5 C#
0x1D in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:23,26 C#
0x17 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw C#
0x6 in System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0 C#
0xC in Android.App.SyncContext. at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36,19 C#
0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6 C#
0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:84,4 C#
0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22,5 C#
]```
Let's assume that I have the following code for v4
client.Users[userId].CalendarView.Request(queryOptions).Filter(filterQuery).Expand(expandOptions).Select(SelectQuery).GetAsync()
The code for v5 looks like this but there is no Expand property in
CalendarViewRequestBuilderGetQueryParameters
classclient .Users[userId] .CalendarView .GetAsync(cfg => { cfg.QueryParameters.StartDateTime = from; cfg.QueryParameters.EndDateTime = to; cfg.QueryParameters.Filter = filterQuery; cfg.QueryParameters.Select = SelectQuery; })
Is it a bug or is there any other reason why Expand property is missing in
CalendarViewRequestBuilderGetQueryParameters
?
Metadata issue tracked via https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1581
Greetings,
I am receiving the error message "Microsoft.Graph.Models.ODataErrors.ODataError: 'Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown.'" leveraging .NET MAUI 7.0 with Microsoft.Graph to execute WindowsAutoPilotDeviceIdentity.UpdateDeviceProperties. I submitted the below to stackoverflow when running 5.0.0 preview 14, though, I am still getting the same error after the update to 5.0.0-rc.1. Is there an issue with my code, or is this not supported with maui?
Stackoverflow question URL: https://stackoverflow.com/questions/74816802/how-do-i-leverage-microsoft-graph-to-update-autopilot-information
public async Task<bool> UpdateAutopilotDeviceAsync(string managedDeviceId, UpdateDevicePropertiesPostRequestBody updateParameters) { if (_graphServiceClient == null) { await SignInAndInitializeGraphServiceClient(); } try { //LINE THROWING ERROR HERE await _graphServiceClient.DeviceManagement.WindowsAutopilotDeviceIdentities[managedDeviceId].UpdateDeviceProperties.PostAsync(updateParameters); //LINE THROWING ERROR HERE return await Task.FromResult(true); } catch { }
private async void Save_Clicked(object sender, EventArgs e) { string managedDeviceId = Device.ManagedDeviceId; UpdateDevicePropertiesPostRequestBody updateParameters = new() { UserPrincipalName = Device.UserPrincipalName, AddressableUserName = Device.AddressableUserName, GroupTag = Device.GroupTag, DisplayName = Device.DisplayName }; await PublicClientSingleton.Instance.MSGraphHelper.UpdateAutopilotDeviceAsync(managedDeviceId, updateParameters); }
Stack trace:
0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5 C# 0x1D in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:23,26 C# 0x17 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw C# 0x6 in System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0 C# 0xC in Android.App.SyncContext. at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36,19 C# 0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6 C# 0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:84,4 C# 0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22,5 C# ]```
We're following up on the linked Stack overflow question
var item = await graphServiceClient.Drives["drive-id"].Items["item-id"] .ItemWithPath(Path.GetFileName("data/sample.pdf")) .Content .GetAsync(); var item2 = await graphServiceClient.Drives["ils"].Root .ItemWithPath(Path.GetFileName("sample.pdf")) .Content .GetAsync();
More information on the drive paths is documented at the link below.
Thanks. So officially there are the endpoints:
GET /me/drive/root:/{item-path}
GET /drives/{drive-id}/root:/{item-path}
The .me I was not able to figure out a way to generate although it does work with a manually composed request. The second one does work, but there seems to be a 3rd option and that is using "Me" for the drive ID which works and eliminates the extra request.
// The below two commented lines do work, but you can also just do the active line below them instead.
//var myDrive = await graphClient.Me.Drive.GetAsync();
//var file = await graphClient.Drives[myDrive.Id].Root
var file = await graphClient.Drives["Me"].Root
.ItemWithPath(path)
.GetAsync()
How to get id of uploaded file?
I have the following code to upload file.
PutAsync()
doesn't return any response but PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
returns driveItem
await _graphServiceClient.Drives[{drive-id}].Root.ItemWithPath({filename}).Content.PutAsync(file);
now I need to make one extra request
var driveItem = await _graphServiceClient.Drives[{drive-id}].Root.ItemWithPath({filename}).GetAsync();
To create a new table I can call
POST https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/add
Content-type: application/json
{
"address": "Sheet1!A1:D5",
"hasHeaders": true
}
In code I can call
await _graphServiceClient.Drives[driveId].Items[itemId].Workbook.Tables.PostAsync(WorkbookTable);
but WorkbookTable
doesn't have address
and hasHeaders
properties.
I don't see any way how to add data to a worksheet. There is no PostAsync()
method for MicrosoftGraphRange
await _graphServiceClient.Drives[driveId].Items[itemId].Workbook.Worksheets[sheetId].Tables[tableId].MicrosoftGraphRange.PostAsync();
Cannot expand attachments for messages. There is no Expand property
var messagesResponse = await _client.Me.Messages.GetAsync(x=>
{
x.QueryParameters.Select = new string[] { "id", "createdDateTime" };
x.QueryParameters.Expand = new string[] { "attachments" };
});
@andrueastman
There is tens of CreateUploadSessionPostRequestBody
classes in different namespaces with very very long names.
It's quite complicated to use the correct CreateUploadSessionPostRequestBody
class. If I use more than one CreateUploadSessionPostRequestBody
from different namespace then I need to specify the class like this and it makes the code unreadable
var uploadSessionOne = new Microsoft.Graph.Drives.Item.Items.Item.MicrosoftGraphCreateUploadSession.CreateUploadSessionPostRequestBody{};
var uploadSessionTwo = new Microsoft.Graph.Users.Item.Todo.Lists.Item.Tasks.Item.Attachments.MicrosoftGraphCreateUploadSession.CreateUploadSessionPostRequestBody {};
hi there,
i started using ms graph .net sdk last week and implemented my requirements with v4 (wasn't avare of v5 until it was released). after a very short ride with v5 today, i got stuck: i need to consume delta functions and could not find a way to send $deltatoken
on v5. i searched the docs but could not find anything relevant (sorry if i missed it); where can i get guidance on this?
Cannot expand attachments for messages. There is no Expand property
var messagesResponse = await _client.Me.Messages.GetAsync(x=> { x.QueryParameters.Select = new string[] { "id", "createdDateTime" }; x.QueryParameters.Expand = new string[] { "attachments" }; });
@andrueastman
Tracked via https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1672
To create a new table I can call
POST https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/add Content-type: application/json { "address": "Sheet1!A1:D5", "hasHeaders": true }
In code I can call
await _graphServiceClient.Drives[driveId].Items[itemId].Workbook.Tables.PostAsync(WorkbookTable);
but
WorkbookTable
doesn't haveaddress
andhasHeaders
properties.I don't see any way how to add data to a worksheet. There is no
PostAsync()
method forMicrosoftGraphRange
await _graphServiceClient.Drives[driveId].Items[itemId].Workbook.Worksheets[sheetId].Tables[tableId].MicrosoftGraphRange.PostAsync();
Tracked via https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1672
Thanks for the feedback and trying out the preview everyone. We'll close this issue and track any new issues raised by creating new issues on the repo.
Thanks again!
The Microsoft Graph .NET SDK v5.0.0 is now available for preview!
This updated version features many changes as the SDK is generated with Kiota:
You can go to the upgrade guide for more detailed information on the changes.
For the beta package, please refer to the beta repo.