Problem
itslearninggermany opened this issue · 1 comments
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?
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.