When I try to create an schema extension on a user like this
schemaExtension := graphmodels.NewSchemaExtension()
additionalData := map[string]interface{}{
"extensionName": "dean.ext.test.1",
"theme": "dark",
"color": "purple",
"lang": "English",
}
schemaExtension.SetAdditionalData(additionalData)
if result, err := client.UsersById(userId).Extensions().Post(context.Background(), schemaExtension, nil); err != nil {
I get this error:
Error: error status code received from the API
code: BadRequest
msg: Maximum number of extensions values supported per application is 2.
But I have not created any schema extensions on this user. I created two open extensions, but I should be able to create additional schema extensions.
Why does the error message say that extensions are per application? The code above is trying to create an extension on a particular user, not an application.
I want to remove the extensions on this user, but there is nothing I can find in the portal that shows extensions for a user. Where can I find the extensions on a user in the portal?
The portal does show user attributes which seem to apply to all users. Are user attributes related to extensions? How can I access these user attributes using the msgraph-sdk-go?
2
Answers
The msgraph-sdk-go is currently at v 0.55 and is a non-production preview. After discussing this with some colleagues we've decided to drop the MS Graph SDK and use the v 1.0 Graph REST endpoints directly. They've had success with that approach and have found that the SDK doesn't help very much.
I tried to reproduce the same in my environment and got below results:
When I ran below request to create extension via Graph Explorer, I got same error as you like below:
Response:
The error usually occurs if you already have 2 open extensions existing in your directory. You can make use of below MS Graph query to list open extensions on a user.
Response:
You can get the same results using
msgraph-sdk-go
with below code:To delete extension from user, you can use below query by including extension name like this:
Response:
You can delete open extension from user using
msgraph-sdk-go
with below code:When I ran the query to list open extensions now, I got only 1 extension in response as other one is deleted successfully like below:
Response:
The code you are currently using to create schema extensions is creating
open extensions
.To create schema extension using
msgraph-sdk-go
, once cross-check your code with below sample code:Reference: Create schemaExtension – Microsoft Graph v1.0
UPDATE:
As mentioned in your answer,
THE GO SDK IS IN PREVIEW. IT IS FOR NON-PRODUCTION USE ONLY
. So, it’s better to stick with REST API calls, for now, to manage resources via MS Graph.