Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot process input of abstract type 'microsoft.graph.extension' #2516

Open
vknht opened this issue May 24, 2024 · 5 comments
Open

Cannot process input of abstract type 'microsoft.graph.extension' #2516

vknht opened this issue May 24, 2024 · 5 comments
Labels
Needs: Attention 👋 type:bug A broken experience type:question An issue that's a question

Comments

@vknht
Copy link

vknht commented May 24, 2024

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 (#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 ```
</details>


### Configuration

- OS: Windows 10
- Architecture: x64 (AMD Ryzen 7 1700)

### Other information

_No response_
@vknht vknht added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels May 24, 2024
@andrueastman
Copy link
Member

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);

@andrueastman andrueastman added type:question An issue that's a question status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels May 27, 2024
@vknht
Copy link
Author

vknht commented May 27, 2024

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?

@vknht
Copy link
Author

vknht commented Jun 4, 2024

anything new?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Status: No recent activity labels Jun 4, 2024
@andrueastman
Copy link
Member

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);

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Jun 4, 2024
@vknht
Copy link
Author

vknht commented Jun 4, 2024

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 type:bug A broken experience type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

2 participants