Open vknht opened 1 month ago
Thanks for raising this @vknht
Any chance you get a different result if you do something like this?
var extension = new OpenTypeExtension();
extension.AdditionalData["MyProperty"] = "MyNewValue";
await graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].PatchAsync(extension);
Hi,
this is interesting. If I do something like this:
var extension = (await _graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].GetAsync()) as OpenTypeExtension;
extension.AdditionalData["MyProperty"] = "MyNewValue";
var extension02 = new OpenTypeExtension()
{
Id = extension.Id,
AdditionalData = extension.AdditionalData,
ExtensionName = extension.ExtensionName,
OdataType = extension.OdataType,
};
await graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].PatchAsync(extension02);
it works. "OdataType" is the same on both instances: "#microsoft.graph.openTypeExtension"
Is there a better way of doing this instead of mapping everything into a new instance?
anything new?
I believe the behaviour you're seeing is due to the backingStore. You can therefore probably use this instead to ensure the entire payload is serialized.
var extension = await graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].GetAsync();
extension.AdditionalData["MyProperty"] = "MyNewValue";
// reset the backing store to force the client to send the full object
extension.BackingStore.InitializationCompleted = false;
await graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].PatchAsync(extension);
hi,
i just tried the
extension.BackingStore.InitializationCompleted = false;
and it worked.
This is much better than creating a new instance and assigning the values. Will this "fix" be implemented in a future version?
Thank you very much so far.
Describe the bug
Hello,
I am trying to load an Extension for a Contact, Change a Value then save it, but i am getting the Error in the title. I found this (https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1723) issue before, but there, a contact is loaded and then the Extension is changed. In my case, i am loading the Extension and nothing else.
Expected behavior
not getting an error i guess?
How to reproduce
var extension = (await _graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].GetAsync()) as OpenTypeExtension;
extension.AdditionalData["MyProperty"] = "MyNewValue";
await _graphClient.Me.ContactFolders["MyContactFolderId"].Contacts["MyContactId"].Extensions["MyExtension"].PatchAsync(extension);
SDK Version
5.54.0
Latest version known to work for scenario above?
Unknown
Known Workarounds
None
Debug output
Click to expand log
```Configuration
Other information
No response