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

Problem #14

Open
itslearninggermany opened this issue Apr 16, 2020 · 1 comment
Open

Problem #14

itslearninggermany opened this issue Apr 16, 2020 · 1 comment

Comments

@itslearninggermany
Copy link

I want to add a new License to a user:

newLicense := msgraph.AssignedLicense{
	SKUID:         &skui,
}

_, err = p.graphClient.Users().ID(*user.ID).AssignLicense(&msgraph.UserAssignLicenseRequestParameter{
	AddLicenses:    []msgraph.AssignedLicense{newLicense},
	RemoveLicenses: []msgraph.UUID{},
}).Request().Post(p.ctx)

I Get this response:
400 Bad Request: {"error":{"code":"Request_BadRequest","message":"Cannot convert a primitive value to the expected type 'Edm.Guid'. See the inner exception for more details.","innerError":{"date":"2020-04-16T22:07:51","request-id":"7d9ce15b-053c-47da-9bc7-c19eb0335462"}}}

what I am doing wrong?

@yaegashi
Copy link
Owner

yaegashi commented Apr 18, 2020

That error message implies you passed a non-GUID string as SKUID.

Another problem I found today is that you cannot omit removeLicenses for assignLicense action parameter, but for now it's impossible to pass an empty slice for it with UserAssignLicenseRequestParameter (because of json:"removeLicenses,omitempty"). I suggest the following as a workaround:

guid := msgraph.UUID("c42b9cae-ea4f-4ab7-9717-81576235ccac")
reqObj := map[string]interface{}{
	"addLicenses":    []msgraph.AssignedLicense{msgraph.AssignedLicense{SKUID: &guid}},
	"removeLicenses": []msgraph.UUID{},
}
err := graphClient.Me().Request().JSONRequest(ctx, "POST", "/assignLicense", reqObj, nil)
if err != nil {
	log.Println(err)
}

Yet another information for you: I'm planning to rename msgraph.UUID to msgraph.GUID, so please prepare for the changes in future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants