Microsoft Graph SDK for Go

Microsoft Graph SDK for Go

PkgGoDev

Get started with the Microsoft Graph SDK for Go by integrating the Microsoft Graph API into your Go application!

Note: this SDK allows you to build applications using the v1.0 of Microsoft Graph. If you want to try the latest Microsoft Graph APIs under beta, use our beta SDK instead.

Note: the Microsoft Graph Go SDK is currently in Community Preview. During this period we're expecting breaking changes to happen to the SDK based on community's feedback. Checkout the known limitations.

1. Installation

go get -u github.com/microsoftgraph/msgraph-sdk-go
go get -u github.com/Azure/azure-sdk-for-go/sdk/azidentity

2. Getting started

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an AuthenticationProvider object

An instance of the GraphRequestAdapter class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

For an example of how to get an authentication provider, see choose a Microsoft Graph authentication provider.

Note: we are working to add the getting started information for Go to our public documentation, in the meantime the following sample should help you getting started.

import (
    azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    a          "github.com/microsoft/kiota/authentication/go/azure"
    "context"
)

cred, err := azidentity.NewDeviceCodeCredential(&azidentity.DeviceCodeCredentialOptions{
    TenantID: "<the tenant id from your app registration>",
    ClientID: "<the client id from your app registration>",
    UserPrompt: func(ctx context.Context, message azidentity.DeviceCodeMessage) error {
        fmt.Println(message.Message)
        return nil
    },
})

if err != nil {
    fmt.Printf("Error creating credentials: %v\n", err)
}

auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"Mail.Read", "Mail.Send"})
if err != nil {
    fmt.Printf("Error authentication provider: %v\n", err)
    return
}

2.3 Get a Graph Service Client Adapter object

You must get a GraphRequestAdapter object to make requests against the service.

import msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"

adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
if err != nil {
    fmt.Printf("Error creating adapter: %v\n", err)
    return
}
client := msgraphsdk.NewGraphServiceClient(adapter)

3. Make requests against the service

After you have a GraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get the user's drive

To retrieve the user's drive:

result, err := client
  .Me()
  .Drive()
  .Get(nil)
if err != nil {
    fmt.Printf("Error getting the drive: %v\n", err)
}
fmt.Printf("Found Drive : %v\n", result.GetId())

4. Documentation

For more detailed documentation, see:

5. Issues

For known issues, see issues.

6. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

7. License

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

8. Third-party notices

Third-party notices

Owner
Microsoft Graph
Unified endpoint for accessing data, relationships and insights coming from the Microsoft cloud
Microsoft Graph
Comments
  • Query Parameters are not working due to missing $ prefix in logic

    Query Parameters are not working due to missing $ prefix in logic

    As mentioned in #114, AddQueryParameters which sets the $search, $expand, $top, $skip etc. in github.com/microsoft/[email protected]/request_information.go is using reflection to name the parameters which you are adding to your URLs in all API calls (e.g. (m *UsersRequestBuilder) CreateGetRequestInformation(options *UsersRequestBuilderGetOptions)).

    Unfortunately you need to inject some additional logic as the MS Graph query parameters require the $ ODATA prefix.

    This means no API calls work as soon as you supply query parameters (so no paging, no filtering, no field fetching) otherwise you get an error like:

    Request_BadRequest: Unrecognized query argument specified: 'top,skip'.: error status code received from the API

    I believe you should be able to fix this inside this library - the logic in microsoft/kiota-abstractions-go isn't wrong, you just can't use the final results in this library because of MS graph API / OData requirements for the $ prefix.

  • Trying to add member to group

    Trying to add member to group

    Hello,

    Using this example to attempt to add a member to an azure ad group.

    I have this bit of code

    graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
    
    requestBody := msgraphsdk.New()
    requestBody.SetAdditionalData(map[string]interface{}{
    	"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/<userid>",
    }
    groupId := "<objectid for group>"
    add, err := graphClient .GroupsById(&groupId).Members().Ref().Post(requestBody)
    

    I get below error

    Exception has occurred: panic
    "interface conversion: interface is nil, not ref.Refable"
    Stack:
    	3  0x0000000000c73d37 in github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).PostWithRequestConfigurationAndResponseHandler
    	    at /home/anthony/go/pkg/mod/github.com/microsoftgraph/[email protected]/groups/item/members/ref/ref_request_builder.go:142
    	4  0x0000000000c73977 in github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).Post
    	    at /home/anthony/go/pkg/mod/github.com/microsoftgraph/[email protected]/groups/item/members/ref/ref_request_builder.go:126
    

    It seems to be this line specifically that is panicking https://github.com/microsoftgraph/msgraph-sdk-go/blob/main/groups/item/members/ref/ref_request_builder.go#L144

    When debugging things I notice that the value for res Here is github.com/microsoft/kiota-abstractions-go/serialization.Parsable nil which I believe explains the error I'm getting

    Its possible I'm doing something horrible wrong, namely the add line add, err := graphClient .GroupsById(&groupId).Members().Ref().Post(requestBody) Am I using the .Ref() portion properly?

    Oddly enough the user is being added to the group successfully. So the add is working minus the fatal panic 😄

  • There is no way to list items in the drive

    There is no way to list items in the drive

    It seems like there's currently no way of actually listing drive items. Requests like: GET /me/drive/root/children or GET /drives/{drive-id}/items/{item-id}/children are not possible using this sdk it seems.

    I would expect to be able to do something like client.Me().Drive().Root().Children().Get(nil)

    Am I missing something or is this just not possible? Also it seems that it's possible to construct invalid requests as in doing GET /drive/items and it just fails silently.

  • Regression in API behavior between v0.26.0 and the newly published v0.29.0

    Regression in API behavior between v0.26.0 and the newly published v0.29.0 "UpdateUser"

    First Issue:

    Previously using v0.26.0, the below snippet of code ran without any issue, however after upgrading to v0.29.0 I'm getting the following error "API call failed with the following error(s): \n > Message: Resource '' does not exist or one of its queried reference-property objects are not present.\n > Code: Request_ResourceNotFound\n"

    The reason for calling update immediately after creating the invite is because the Invitation api does not allow a user to set the firstName (givenname) and lastName (surname) fields, so those have to be done separately as another api call.

    func (gc *msgraphclient) CreateUser(u *User) (*User, error) {
    
    	if u == nil {
    		return nil, ErrUserNotSpecified
    	}
    
    	requestBody := models.NewInvitation()
    	requestBody.SetInvitedUserEmailAddress(&u.Username)
    	inviteRedirectUrl := fmt.Sprintf("https://portal.azure.com/%s", gc.config.TenantId)
    	requestBody.SetInviteRedirectUrl(&inviteRedirectUrl)
    	requestBody.SetInvitedUserDisplayName(&u.DisplayName)
    
    	resp, err := gc.appClient.Invitations().Post(requestBody)
    	if err != nil {
    		return nil, err
    	}
    
    	u.Id = *resp.GetInvitedUser().GetId()
    	_, err = gc.UpdateUser(u)
    	if err != nil {
    		log.Error("error updating user after creating invitation")
    		return nil, err
    	}
    	return u, nil
    }
    
    func (gc *msgraphclient) UpdateUser(u *User) (*User, error) {
    
    	if u == nil {
    		return nil, ErrUserNotSpecified
    	}
    
    	requestBody := models.NewUser()
    	requestBody.SetAccountEnabled(&u.AccountEnabled)
    	requestBody.SetDisplayName(&u.DisplayName)
    	requestBody.SetGivenName(&u.GivenName)
    	requestBody.SetSurname(&u.Surname)
    	requestBody.SetMail(&u.Email)
    
    	err := gc.appClient.UsersById(u.Id).Patch(requestBody)
    	if err != nil {
    		return nil, err
    	}
    
    	return u, nil
    }
    

    Second Issue:

    Even with the below code, which is able to successfully find the user by email, throws the same error as the first issue when trying to update existing users (both invitation & non-invitation) in the Microsoft Graph.

    func (gc *msgraphclient) UpdateUser(emailAddress, firstName, lastName string) error {
    
    	err := g.EnsureGraphForAppOnlyAuth()
    	if err != nil {
    		return err
    	}
    
    	targetUser, _ := gc.FindUserByEmail(emailAddress)
    	targetUser.SetGivenName(&firstName)
    	targetUser.SetSurname(&lastName)
    
    	err = g.appClient.UsersById(*targetUser.GetId()).Patch(targetUser)
    	if err != nil {
    		return err
    	}
    
    	return nil
    }
    
    func (gc *msgraphclient) FindUserByEmail(email string) (models.Userable, error) {
    
    	filter := fmt.Sprintf("mail eq '%s' and creationType eq 'Invitation'", email)
    	fields := []string{"id", "userPrincipalName", "displayName", "givenName", "surname", "mail", "accountEnabled"}
    	requestParameters := &users.UsersRequestBuilderGetQueryParameters{
    		Filter: &filter,
    		Select: fields,
    	}
    	options := &users.UsersRequestBuilderGetRequestConfiguration{
    		QueryParameters: requestParameters,
    	}
    
    	resp, err := gc.appClient.Users().GetWithRequestConfigurationAndResponseHandler(options, nil)
    	if err != nil {
    		return nil, err
    	}
    
    	users := resp.GetValue()
    	if len(users) <= 0 {
    		return nil, errors.New("user not found")
    	} else if len(users) > 1 {
    		return nil, errors.New("duplicate users found")
    	}
    	msUser := users[0]
    
    	return msUser, nil
    }
    

    Given the above, all signs point to there being a critical regression in the logic for the UpdateUser endpoint.

    Just for context, I've tried using both the object ID and userPrincipalName as "userId" values when calling the UpdateUser method, neither makes a difference and I still get an error.

    P.S - The same "UpdateUser" function above which previously executed without any issue sometimes throws the following error as well but I'm not able to consistently reproduce --> Specified HTTP method is not allowed for the request target.\n > Code: Request_BadRequest\n

  • Allow passing context in requests

    Allow passing context in requests

    Currently the msgraph-sdk-go doesn't allow passing the context when making requests which removes the ability to cancel API requests when the context is canceled.

    Example usage could look like:

    user, err := client.Me().GetWithContext(ctx)
    
    user, err := client.Me().GetWithRequestConfigurationAndResponseHandlerWithContext(ctx, options, nil)
    
  • unable to create messages subscription

    unable to create messages subscription

    1. from MS GRAPH

    POST /?validationToken=Validation%3a+Testing+client+application+reachability+for+subscription+Request-Id%3a+5731e5c5-096b-867f-5fd1-b1fc2e93c359 HTTP/1.1 Host: b75a-2402-e280-218f-146-cc28-275-9540-2bb8.in.ngrok.io Content-Length: 0 Accept: text/plain Content-Type: text/plain; charset=utf-8 X-Forwarded-For: 20.44.210.146 X-Forwarded-Proto: https Accept-Encoding: gzip

    1. End point response (End point validation step)

    HTTP/1.1 200 OK Date: Thu, 11 Aug 2022 11:20:44 GMT Content-Length: 121 Content-Type: text/plain; charset=utf-8

    Validation%3a+Testing+client+application+reachability+for+subscription+Request-Id%3a+5731e5c5-096b-867f-5fd1-b1fc2e93c359

    1. ERROR on MS GRAPH EXplorer

    { "error": { "code": "InvalidRequest", "message": "Subscription validation request failed. Response must exactly match validationToken query parameter.", "innerError": { "date": "2022-08-11T11:25:25", "request-id": "b3a974a5-af61-4d78-99d2-7e5f63d7ecf1", "client-request-id": "96dd0a46-094a-e661-d992-b2d280310a02" } } }

    Q. What is wrong in above code? I am not able to create subscription.

  • New Users throwing inconsistent error

    New Users throwing inconsistent error

    Hello,

    I'm using this SDK to create new Azure AD users newUser, err := c.Users().Post(requestBody) is a snippet of the code I'm using

    While testing the code in my lab there are times when the Post will randomly fail I've extracted the error Code and Message when it fails

    Code=BadRequest
    message=Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.
    

    There aren't any failures logged in Azure (which makes sense based on the error)

    I'm wondering why (if anything) can be done to prevent this error As I said the error is very intermittent. If I run the code again right away it might succeed.

    For example, I added a test to range over 5 users and create them. If I run it 10-15 times I would say every time I run it I'll get at least 1-2 failures. There is no rhyme or reason which users will fail. I suppose I could write my own retry where if that error presents itself it just tries again, but figured I would reach out in case I'm missing something

  • 'contentType is required' error when adding a chat member

    'contentType is required' error when adding a chat member

    This looks like it might be the same issue as #205 but I'm getting it when trying to add a member to a chat.

    I'm essentially using the code from here and I'm getting the contentType is required error, but the member is added successfully.

    func (m *MSTeamsModel) AddMember(chatid, email string) error {
    	conversationMember := graphmodels.NewConversationMember()
    	odatatype := "#microsoft.graph.aadUserConversationMember"
    	conversationMember.SetOdataType(&odatatype)
    	roles := []string{
    		"owner",
    	}
    	conversationMember.SetRoles(roles)
    	additionalData := map[string]interface{}{
    		"[email protected]": fmt.Sprintf("https://graph.microsoft.com/v1.0/users('%s')", email),
    	}
    	conversationMember.SetAdditionalData(additionalData)
    	visibleHistoryStartDateTime, _ := time.Parse(time.RFC3339, "0001-01-01T00:00:00Z")
    	conversationMember.SetVisibleHistoryStartDateTime(&visibleHistoryStartDateTime)
    	_, err := m.Client.ChatsById(chatid).Members().Post(conversationMember)
    	if err != nil {
    		printOdataError(err)
    		return fmt.Errorf("error adding member: %w", err)
    	}
    	return nil
    }
    

    Versions from go.mod when downloaded originally:

    github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.0 // indirect
    github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 // indirect
    github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
    github.com/microsoft/kiota-abstractions-go v0.8.2 // indirect
    github.com/microsoft/kiota-authentication-azure-go v0.3.1 // indirect
    github.com/microsoft/kiota-http-go v0.5.2 // indirect
    github.com/microsoft/kiota-serialization-json-go v0.5.5 // indirect
    github.com/microsoft/kiota-serialization-text-go v0.4.1 // indirect
    github.com/microsoftgraph/msgraph-sdk-go v0.34.0 // indirect
    github.com/microsoftgraph/msgraph-sdk-go-core v0.27.0 // indirect
    

    Just performed a go get -u github.com/microsoftgraph/msgraph-sdk-go which updated these -- issue persists:

    go: downloading github.com/microsoft/kiota-http-go v0.6.0
    go: upgraded github.com/microsoft/kiota-http-go v0.5.2 => v0.6.0
    go: upgraded github.com/microsoftgraph/msgraph-sdk-go v0.34.0 => v0.35.0
    

    Many thanks for any information you can provide.

  • Can't call Post() method to create/modify objects

    Can't call Post() method to create/modify objects

    Hi,

    I'd like to add a user to a group, according to the documentation and the code I should make this kind of call:

    graphClient.GroupsById(idGroup).MembersById(idUser).Post(directoryobject)
    

    However, the Post method doesn't exist, same thing happen if I want to add a user to a directoryRole.

    I might be missing something, but I can't figure it out.

    Thanks for your work :)

  • Query parameter does not work properly when retrieving users

    Query parameter does not work properly when retrieving users

    Hi

    I have created a sample program to retrieve a user, but the query parameter does not seem to be working correctly. When I debug it, it seems that the query parameter is not set correctly, is it still a limitation?

    The following sample query for the CreatedDateTime property to be included in the response, but returns NULL.

    func getUser(client *msgraphsdk.GraphServiceClient, id string) {
    
    	options := &usersitem.UserRequestBuilderGetOptions{
    		Q: &usersitem.UserRequestBuilderGetQueryParameters{
    			Select_escaped: []string{"createdDateTime"},
    		},
    	}
    	result, err := client.UsersById(id).Get(options)
    	if err != nil {
    		fmt.Printf("Error get user : %v\n", err)
    		return
    	}
    
    	fmt.Printf("result.GetDisplayName(): %v\n",result.GetDisplayName())
    	fmt.Printf("result.GetCreatedDateTime(): %v\n", result.GetCreatedDateTime())
    }
    

    Thanks.

  • Failing to query for report

    Failing to query for report

    Hi,

    I wanted to test if I could use this library for one usecase and stumbled over an error. After debugging it seems that the uri-template parser does not like the character ' which is present in the URI.

    URI is set here and looks like this "{+baseurl}/reports/microsoft.graph.getOffice365ActiveUserDetail(period='{period}')"

    Template parsing happens here

    The error I get is this one Error getting the report: uritemplate:72:invalid literals

    Code

    func GetReport() {
    	//auth
    	cred, err := azidentity.NewClientSecretCredential(
    		"x",
    		"x",
    		"x",
    		nil,
    	)
    
    	if err != nil {
    		fmt.Printf("Error creating credentials: %v\n", err)
    	}
    
    	auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{".default"})
    	if err != nil {
    		fmt.Printf("Error authentication provider: %v\n", err)
    		return
    	}
    
    	adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
    	if err != nil {
    		fmt.Printf("Error creating adapter: %v\n", err)
    		return
    	}
    	client := msgraphsdk.NewGraphServiceClient(adapter)
    
    
    	period := "D7"
    	result, err := client.Reports().GetOffice365ActiveUserDetailWithPeriod(&period).Get(nil)
    	if err != nil {
    		fmt.Printf("Error getting the report: %s\n", err)
    		return
    	}
    	fmt.Printf("Found Drive : %v\n", result.GetContent())
    }
    

    BR Henry

  • Cannot create table: table does not exist

    Cannot create table: table does not exist

    Hi, trying to create a table if it does not exist.

    	tablesClient, err := insights.NewTablesClient(creds.SubscriptionID, cred, nil)
    	if err != nil {
    		return fmt.Errorf("could not create ms graph table client: %v", err)
    	}
    
    	retention := int32(retentionDays)
    
    	poller, err := tablesClient.BeginCreateOrUpdate(
    		ctx, creds.ResourceGroup, creds.WorkspaceName, vuln.TableNameVulnerabilities,
    		insights.Table{
    			Properties: &insights.TableProperties{
    				RetentionInDays: &retention,
    				Schema: &insights.Schema{
    					Columns: []*insights.Column{
    						{
    							Description: to.Ptr("The vulnerability name"),
    							Name:        to.Ptr("Name"),
    							Type:        to.Ptr(insights.ColumnTypeEnumString),
    						},
    					},
    					DisplayName: to.Ptr(vuln.TableNameVulnerabilities),
    					Name:        to.Ptr(vuln.TableNameVulnerabilities),
    				},
    				TotalRetentionInDays:   &retention,
    				ArchiveRetentionInDays: nil,
    			},
    		}, nil)
    	if err != nil {
    		return fmt.Errorf("could not create table '%s': %v", vuln.TableNameVulnerabilities, err)
    	}
    
    	_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{Frequency: time.Second * 3})
    	if err != nil {
    		return fmt.Errorf("could not poll table creation: %v", err)
    	}
    
    	logger.WithField("table_name", vuln.TableNameVulnerabilities).Info("created table")
    

    However, this returns the error:

    "could not create table 'Vulnerabilities': PUT https://management.azure.com/subscriptions/xxx/resourcegroups/siem/providers/Microsoft.OperationalInsights/workspaces/sentinelsiem/tables/Vulnerabilities\n--------------------------------------------------------------------------------\nRESPONSE 404: 404 Not Found\nERROR CODE: ResourceNotFound\n--------------------------------------------------------------------------------\n{\n  \"error\": {\n    \"code\": \"ResourceNotFound\",\n    \"message\": \"The specified table: 'Vulnerabilities' does not exist. Operation Id: '1a906d5e3546c7845a12552db9b41b6c'\"\n  }\n}\n--------------------------------------------------------------------------------\n
    

    Any idea why it is complaining the table does not exist while it should create it?

  • Skip generation for the /me endpoints

    Skip generation for the /me endpoints

    Capturing this as we've talked about it internally but haven't captured it in the backlog yet.

    /me and /users/{id} are effectively identical from a metadata perspective. This presents an opportunity to reduce build time further (~17% from our early measurements) while minimally impacting the experience for users.

    TODO:

    • [ ] in graph core, add a UrlReplaceOption request option. It needs to implement the interface and provide accessors for Enabled (default true) as well as "ReplacementPairs" (map[string]string), default [/users/me-token-to-replace, /me]
    • [ ] in graph core add a UrlReplaceHandler that implements the middleware handler, replaces the tokens in the URLs, and traces its activity with the telemetry.
    • [ ] in graph core, add this new handler as part of the defaults
    • [ ] in code generator, update the go weekly generation steps to exclude /me (exclude paths, /me and /me/**, or something similar)
    • [ ] trigger a code generation from beta
    • [ ] in that newly generated PR, update the dependency to core
    • [ ] in that newly generated PR, cherry pick the first commit from #333
    • [ ] update the snippets generation to map inline types for /me to /users
  • Missing DeviceEnrollmentType value

    Missing DeviceEnrollmentType value

    While iterating on devices, it is failing due to missing 'DeviceEnrollmentType' value. See the following error output: unable to list devices: Unknown DeviceEnrollmentType value: azureAdJoinUsingAzureVmExtension

    Is there any reason why some values have not been implemented in this sdk while it has been done on msgraph-beta-sdk-go ? See https://github.com/microsoftgraph/msgraph-beta-sdk-go/blob/62848feaab6cd72535d80d10949407ba11f3662f/models/device_enrollment_type.go

  • innererror not deserialized in some ODataErrors

    innererror not deserialized in some ODataErrors

    Follow up from https://github.com/microsoftgraph/msgraph-sdk-go/discussions/218#discussioncomment-4335452.

    It seems like we'd expect the innererror to be populated but it is not. instead, the innerError is stuffed into additionalData

    minimal repro:

    output:

    (*odataerrors.ODataError)(0x140005b8240)(error status code received from the API)
     map[] (abstractions.ApiError) error status code received from the API
     (*odataerrors.MainError)(0x1400014e3c0)({
     additionalData: (map[string]interface {}) (len=1) {
      (string) (len=10) "innerError": (map[string]*jsonserialization.JsonParseNode) (len=3) {
       (string) (len=4) "date": (*jsonserialization.JsonParseNode)(0x14000112250)({
        value: (*string)(0x14000112240)((len=19) "...")
       }),
       (string) (len=10) "request-id": (*jsonserialization.JsonParseNode)(0x140001122b0)({
        value: (*string)(0x140001122a0)((len=36) "...")
       }),
       (string) (len=17) "client-request-id": (*jsonserialization.JsonParseNode)(0x14000112310)({
        value: (*string)(0x14000112300)((len=36) "...")
       })
      }
     },
     code: (*string)(0x14000112160)((len=18) "Request_BadRequest"),
     details: ([]odataerrors.ErrorDetailsable) <nil>,
     innererror: (odataerrors.InnerErrorable) <nil>,
     message: (*string)(0x140001121c0)((len=99) "One or more added object references already exist for the following modified properties: 'members'."),
     target: (*string)(<nil>)
    })
    

    Here's a minimal repro that attempts to add a user to a group they already exist in (must set that up before running):

    package main
    
    import (
    	"context"
    	"fmt"
    	"log"
    
    	azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    	"github.com/davecgh/go-spew/spew"
    	a "github.com/microsoft/kiota-authentication-azure-go"
    	msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
    	"github.com/microsoftgraph/msgraph-sdk-go/models"
    	"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
    )
    
    func main() {
    	ctx := context.Background()
    	cred, err := azidentity.NewClientSecretCredential("...", "...", "...", nil)
    	if err != nil {
    		panic(err)
    	}
    
    	auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{})
    	if err != nil {
    		panic(err)
    	}
    
    	adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
    	if err != nil {
    		panic(err)
    	}
    
    	client := msgraphsdk.NewGraphServiceClient(adapter)
    
    	req := models.NewReferenceCreate()
    	id := fmt.Sprintf(
    		"https://graph.microsoft.com/v1.0/directoryObjects/%s",
    		"some-user-id-that-is-already-in-the-group",
    	)
    	req.SetOdataId(&id)
    	if err := client.GroupsById("some-group-id").Members().Ref().Post(ctx, req, nil); err != nil {
    		if odataErr, ok := err.(*odataerrors.ODataError); ok {
    			log.Println("error", spew.Sdump(odataErr))
    		}
    		panic(err)
    	}
    
    	panic("expected panic above")
    }
    
  • users/item/messages/count.CountRequestBuilderGetRequestConfiguration is missing a QueryParameters field

    users/item/messages/count.CountRequestBuilderGetRequestConfiguration is missing a QueryParameters field

    Hi, I'm trying to count the number of messages that match a specific filter using something like this:

    import "github.com/microsoftgraph/msgraph-sdk-go/users/item/messages/count"
    
    var options count.CountRequestBuilderGetRequestConfiguration
    
    filter = "isDraft eq false"
    options.QueryParameters.Filter = &filter
    
    client.UsersById(userId).Messages().Count().Get(context.Background(), &options)
    

    However, the CountRequestBuilderGetRequestConfiguration struct does not contain a QueryParameters field.

    I'd expect this request configuration object to match github.com/microsoftgraph/msgraph-sdk-go/users/item/messages.MessagesRequestBuilderGetQueryParameters - where this field is present and behaves as expected

    Would you kindly fix this issue?

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs

PnPjs is a fluent JavaScript API for consuming SharePoint and Microsoft Graph REST APIs in a type-safe way. You can use it with SharePoint Framework,

Dec 23, 2022
Microsoft Azure SDK for Go

Azure SDK for Go This repository is for active development of the Azure SDK for Go. For consumers of the SDK you can follow the links below to visit t

Jan 6, 2023
A Facebook Graph API SDK For Go.

A Facebook Graph API SDK In Golang This is a Go package that fully supports the Facebook Graph API with file upload, batch request and marketing API.

Dec 12, 2022
A go sdk for baidu netdisk open platform 百度网盘开放平台 Go SDK

Pan Go Sdk 该代码库为百度网盘开放平台Go语言的SDK

Nov 22, 2022
Nextengine-sdk-go: the NextEngine SDK for the Go programming language

NextEngine SDK for Go nextengine-sdk-go is the NextEngine SDK for the Go programming language. Getting Started Install go get github.com/takaaki-s/nex

Dec 7, 2021
Commercetools-go-sdk is fork of original commercetools-go-sdk

commercetools-go-sdk The Commercetools Go SDK is automatically generated based on the official API specifications of Commercetools. It should therefor

Dec 13, 2021
Sdk-go - Go version of the Synapse SDK

synapsesdk-go Synapse Protocol's Go SDK. Currently in super duper alpha, do not

Jan 7, 2022
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go

Redash Go SDK An SDK for the programmatic management of Redash. The main compone

Dec 13, 2022
Nov 28, 2022
Graph Role-Based Access Control by Animeshon
Graph Role-Based Access Control by Animeshon

gRBAC - Graph Role-Based Access Control A cloud-native graph implementation of the Role-Based Access Control (RBAC) authorization architecture powered

Nov 9, 2022
AWS SDK for the Go programming language.

AWS SDK for Go aws-sdk-go is the official AWS SDK for the Go programming language. Checkout our release notes for information about the latest bug fix

Dec 31, 2022
A Golang SDK for Medium's OAuth2 API

Medium SDK for Go This repository contains the open source SDK for integrating Medium's OAuth2 API into your Go app. Install go get github.com/Medium/

Nov 28, 2022
MinIO Client SDK for Go

MinIO Go Client SDK for Amazon S3 Compatible Cloud Storage The MinIO Go Client SDK provides simple APIs to access any Amazon S3 compatible object stor

Dec 29, 2022
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Nov 4, 2022
Twilight is an unofficial Golang SDK for Twilio APIs
Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs. Twilight was born as a result of my inability to spell Twilio correctly. I searched for a Twillio Golang client library and couldn’t find any, I decided to build one. Halfway through building this, I realized I had spelled Twilio as Twillio when searching for a client library on Github.

Jul 2, 2021
Wechat Pay SDK(V3) Write by Go.

WechatPay GO(v3) Introduction Wechat Pay SDK(V3) Write by Go. API V3 of Office document is here. Features Signature/Verify messages Encrypt/Decrypt ce

May 23, 2022
Go Wechaty is a Conversational SDK for Chatbot Makers Written in Go
Go Wechaty is a Conversational SDK for Chatbot Makers Written in Go

go-wechaty Connecting Chatbots Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 6 lines of Go. Voice of the De

Dec 30, 2022
An easy-to-use unofficial SDK for Feishu and Lark Open Platform

go-lark go-lark is an easy-to-use unofficial SDK for Feishu and Lark Open Platform. go-lark implements messaging APIs, with full-fledged supports on b

Jan 2, 2023
A go SDK for the data available via data.gov.gr

go-data-gov-gr-sdk A Go based SDK to access the public data provided by the Greek Government and are available at https://www.data.gov.gr/ Quick Start

Jan 24, 2022