我尝试使用谷歌表单 API 更新我现有的表单。我在请求中填写了位置字段,但仍然收到来自服务器的错误消息create_item.location.index is invalid or was not provided
创建请求代码
func UpdateForm(formId string, form *forms.Form) *forms.Form {
var requestElements []*forms.Request
// Update form info
requestElements = append(requestElements, &forms.Request{
UpdateFormInfo: &forms.UpdateFormInfoRequest{
Info: form.Info,
UpdateMask: "*",
},
})
// Add items
for i, item := range form.Items {
element := &forms.Request{
CreateItem: &forms.CreateItemRequest{
Item: item,
Location: &forms.Location{Index: int64(i)},
},
}
requestElements = append(requestElements, element)
}
request := forms.BatchUpdateFormRequest{
IncludeFormInResponse: true,
Requests: requestElements,
}
response, err := formService.Forms.
BatchUpdate(formId, &request).
Context(context.TODO()).
Do()
if err != nil {
panic(err)
}
return response.Form
}
注意:我使用的是form apiv1
翻翻过去那场雪
相关分类