msgraph-sdk-go icon indicating copy to clipboard operation
msgraph-sdk-go copied to clipboard

Undefined types in Golang for users related to Delta parameters and configurations

Open Shaka-Man opened this issue 1 year ago • 2 comments

Describe the bug

With an app-only authentication program I am attempting to monitor particular user's mail folder utilizing delta requests. The requests work in Graph Explorer. When utilizing the code snippet built by Explorer for the query an undefined returned for both the Parameters and the Configuration.

The two types in question are users.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetQueryParameters and users.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetRequestConfiguration.

Here is an example of the query used in Explorer: https://graph.microsoft.com/v1.0/users/{id}/mailFolders('inbox')/messages/delta?changeType=created&$select=subject,from,isRead,body,receivedDateTime

The code snippet generated is as follows:

import ( "context" abstractions "github.com/microsoft/kiota-abstractions-go" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphusers "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports )

headers := abstractions.NewRequestHeaders() headers.Add("Prefer", "outlook.body-content-type="text"")

requestChangeType := "created"

requestParameters := &graphusers.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetQueryParameters{ ChangeType: &requestChangeType, Select: [] string {"subject","from","isRead","body","receivedDateTime"}, } configuration := &graphusers.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetRequestConfiguration{ Headers: headers, QueryParameters: requestParameters, }

// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go delta, err := graphClient.Users().ByUserId("user-id").MailFolders().ByMailFolderId("mailFolder-id").Messages().Delta().GetAsDeltaGetResponse(context.Background(), configuration)

Expected behavior

I expected the sample code generated by Graph Explorer to compile

How to reproduce

Place the provided query in Explorer and execute. Review the Golang code snippet and open with vscode. That will immediately highlight the two types as undefined.

SDK Version

1.47.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

undefined: users.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetRequestConfigurationcompilerUndeclaredIm

(undefined: users.UserItemMailFolderItemMessagesDeltaWithRequestBuilderGetQueryParameterscompilerUndeclaredImporte

Configuration

macOS 14.6.1 Apple M3 Pro

Other information

No response

Shaka-Man avatar Sep 01 '24 15:09 Shaka-Man

Hi @Shaka-Man , thank you for testing out the SDK. I've noted the issue with the generated code and it will be fixed on the snippet generation tool

As for now, you can use the sample


	headers := abstractions.NewRequestHeaders()
	headers.Add("Prefer", "outlook.body-content-type=""text""")

	requestChangeType := "created"

	requestParameters := &graphusers.ItemMailFoldersItemMessagesDeltaRequestBuilderGetQueryParameters{
		ChangeType: &requestChangeType,
		Select:     []string{"subject", "from", "isRead", "body", "receivedDateTime"},
	}
	configuration := &graphusers.ItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration{
		Headers:         headers,
		QueryParameters: requestParameters,
	}

	// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
	delta, err := graphClient.Users().ByUserId("user-id").MailFolders().ByMailFolderId("mailFolder-id").Messages().Delta().GetAsDeltaGetResponse(context.Background(), configuration)

rkodev avatar Oct 24 '24 15:10 rkodev

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.