【发布时间】:2022-07-07 02:14:18
【问题描述】:
我目前正在玩 golang 的 microsoft graph api 示例。
我在使用他们的示例之一时遇到以下错误:
"不能使用 '&contentType' (type *string) 作为类型 *BodyType"
在其他示例中,我会理解它只是错误的类型,而不是传入类型 *string 我需要传入例如字符串。
但是我不知道在这种情况下 *BodyType 是什么?他们在这里寻找什么? https://docs.microsoft.com/en-gb/graph/api/message-update?view=graph-rest-1.0&tabs=go
requestBody := msgraphsdkm.NewMessage()
subject := "subject-value"
requestBody.SetSubject(&subject)
body := msgraphsdkm.NewItemBody()
requestBody.SetBody(body)
contentType := ""
body.SetContentType(&contentType)
content := "content-value"
body.SetContent(&content)
inferenceClassification := "other"
requestBody.SetInferenceClassification(&inferenceClassification)
messageId := "message-id"
graphClient.Me().MessagesById(&messageId).Patch(requestBody)
inferenceClassification 也出现同样的错误
不能使用 '&inferenceClassification' (type *string) 作为类型 *InferenceClassificationType 我也不知道这是在找什么?
为基本问题道歉
更新: 根据 Gavins 的评论,它期待一个 int 内容类型:= 1 body.SetContentType((*msgraphsdk.BodyType)(&contentType))
【问题讨论】:
-
假设您使用的是最新版本的 SDK,看起来
BodyType的类型为int而不是string: github.com/microsoftgraph/msgraph-sdk-go/blob/… -
谢谢加文!传奇。这就是答案。
标签: go microsoft-graph-api outlook-restapi