vikadata / vika.go

Vika Golang SDK
MIT License
17 stars 2 forks source link

RecordIds 拼接参数异常 #18

Open shell-echo-helloworld opened 9 months ago

shell-echo-helloworld commented 9 months ago
    var body struct {
        DataSheetID string `json:"datasheet_id"`
        RecordID    string `json:"record_id"`
    }
    if err := gin_context.ShouldBindJSON(&body); err != nil {
        gin_context.Set("resp", err)
        return
    }

    credential := common.NewCredential("**************")
    cpf := profile.NewClientProfile()
    datasheet, _ := vika.NewDatasheet(credential, body.DataSheetID, cpf)
    request := vika.NewDescribeRecordRequest()
    request.RecordIds = common.StringPtrs([]string{body.RecordID})
    records, err := datasheet.DescribeAllRecords(request)
    if err != nil {
        gin_context.Set("resp", err)
        return
    }

    for _, record := range records {
        fmt.Println(
            record.RecordId,
            record.CreatedAt,
        )
        for name, value := range *record.Fields {
            fmt.Println(name, value)
        }
        fmt.Println()
    }

    gin_context.Set("resp", "ok")

其中

        request.RecordIds = common.StringPtrs([]string{body.RecordID}) 

拼接的url 调试结果是

        https://api.vika.cn/fusion/v1/datasheets/datasheet_id/records?pageNum=1&pageSize=1000&recordIds.0=record_id

RecordIds 参数有点问题 recordIdsa.0

shell-echo-helloworld commented 9 months ago

环境:

root@2a971651fb2b:~# go version
go version go1.21.3 linux/amd64
root@2a971651fb2b:~# uname -a
Linux 2a971651fb2b 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 10:33:52 UTC 2 x86_64 GNU/Linux
shell-echo-helloworld commented 9 months ago

截屏2023-10-13 11 03 38 这个地方跟文档定义不太一样 文档定义是以逗号分隔开的 截屏2023-10-13 11 06 06