Ask questionsCannot unmarshal ServicePrincipalListResult in call to graphrbac client.List

Bug Report

  • import path of package in question, e.g. .../services/compute/mgmt/2018-06-01/compute

  • SDK version e.g. master, latest, 18.1.0 27.0

  • Specify the exact commit if possible; one way to get this is the REVISION column output by dep status " d659f2a91175cac99aa5627d09b83026eacc978d

  • output of go version go version go1.12.1 darwin/amd64

  • What happened? I created a Service Principal client using this code:

	log.Infof("Creating a new Service Principal client")

	oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, tenantID)
	if err != nil {
		return nil, err

	token, err := adal.NewServicePrincipalToken(
		*oauthConfig, clientID, clientSecret, azure.PublicCloud.GraphEndpoint)
	if err != nil {
		return nil, err

	mgmtServicePrincipalClient := graphrbac.NewServicePrincipalsClient(tenantID)
	mgmtServicePrincipalClient.Authorizer = autorest.NewBearerAuthorizer(token)

	return &mgmtServicePrincipalClient, nil

I can authenticate/authorize with no problem. This is the problematic code:

	if err != nil {
		log.Errorf("Could not get service principal client: %v", err)
		return "", err

	ctx := context.Background()
	filter := fmt.Sprintf("appId eq '%s'", clientID)
	listPages, err := spClient.List(ctx, filter)
	if err != nil {
		log.Errorf("Could not list service principal client: %v", err)
		return "", err

the call to spClient.List gives me this error:

BadRequest: graphrbac.ServicePrincipalsClient#List: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal bool into Go struct field ServicePrincipalListResult.value of type string'

  • What did you expect or want to happen? If you look at graphrbac.ServicePrincipal.AccountEnabled, it's defined to be a *string. If you change that to a *bool then the code works properly (you also have to change the custom Unmarshal code in models.go...). I would open a PR, but I'm not familiar with how autorest works or where that structure is defined. I'm assuming it's generated? If not, and if it's just a POGO, then let me know and I'll be happy to open a PR. However, I also don't know the complete ramifications of changing the type of this variable in other parts of the SDK.

  • How can we reproduce it? If you need, I can probably cobble together a sample program that will reproduce it, but hopefully that's enough info up above. Let me know if not.

  • Anything we should know about your environment. Mac OS Other than that, nothing special


Answer questions jhendrixMSFT

This has been fixed in


Related questions

SDK equivalent for CLI "az aks install-connector" hot 1
storage.ManagementPoliciesClient.CreateOrUpdate Failed with RequestIsNotValidJson hot 1
Authentication example needed hot 1
`go get` latest fails due to UUID usage hot 1
[Recovery Services] Vague error messages when updating a policy hot 1
[Recovery Services] Vague error messages when updating a policy hot 1
go get module no matching versions for query "latest hot 1
Key Management API for Function App hot 1
Application insights frustration hot 1
AAD Domain Service create/update fails with Request_InvalidDataContractVersion hot 1
Github User Rank List