【问题标题】:Type error trying the microsoft graph api for golang尝试 golang 的 microsoft graph api 时输入错误
【发布时间】: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))

【问题讨论】:

标签: go microsoft-graph-api outlook-restapi


【解决方案1】:

内容类型:= 1 body.SetContentType((*msgraphsdkm.BodyType)(&contentType))

根据 Gavins 的评论,它需要一个 int https://github.com/microsoftgraph/msgraph-sdk-go/blob/eb2d097f9010a618832461f649740084d7823b02/models/body_type.go#L6

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多