我想使用Golang Graph SDK请求用户的日历,但我只是得到随机的Odata值作为响应,而不是Json或其他格式。
首先,我使用Github上的官方文档和问题进行连接和请求:
package main
import (
"context"
"fmt"
azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
a "github.com/microsoft/kiota-authentication-azure-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
cv "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendarview"
)
func main() {
cred, err := azidentity.NewClientSecretCredential(
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
nil,
)
auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"https://graph.microsoft.com/.default"})
adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
client := msgraphsdk.NewGraphServiceClient(adapter)
if err != nil {
fmt.Println("Fehler: ", err)
}
requestStartDateTime := "2022-11-01T00:00:00"
requestEndDateTime := "2022-11-17T00:00:00"
query := cv.CalendarViewRequestBuilderGetQueryParameters{
// Orderby: []string{"start/dateTime"},
StartDateTime: &requestStartDateTime,
EndDateTime: &requestEndDateTime,
Select: []string{
"subject",
"start",
"end",
},
}
options := cv.CalendarViewRequestBuilderGetRequestConfiguration{
QueryParameters: &query,
}
_ = options
result, err := client.UsersById("redacted@domain.com").CalendarView().Get(context.Background(), &options)
if err != nil {
// const colorRed = "