tuya/tuya-connector-go

"param is empty" error

ryanlaycock opened this issue · 0 comments

Hey! Just started using the tuya API and have run into an issue. (Not sure if the issue is specifically with this library or not so maybe this issue should be placed elsewhere?)

When calling the /v1.0/devices endpoint I always get resp:{"code":1100,"msg":"param is empty","success":false} response. I see the page_no and page_size fields are required but setting them as query params and as headers doesn't change the outcome. Please see my attempts below:

connector.InitWithOptions(env.WithApiHost("https://openapi.tuyacn.com"),
        env.WithMsgHost(httplib.MSG_EU),
        env.WithAccessID("<accessID>"),
        env.WithAccessKey("<accessKey>"),
        env.WithAppName("tuyaSDK"),
        env.WithDebugMode(true),
    )
    resp := &[]GetDeviceResponse{}
    ...

I have then tried both

err = connector.MakeGetRequest(
        context.Background(),
        connector.WithAPIUri(fmt.Sprintf("/v1.0/devices?page_no=0&page_size=10")),
        connector.WithResp(resp),
    )

and

err = connector.MakeGetRequest(
        context.Background(),
        connector.WithAPIUri(fmt.Sprintf("/v1.0/devices")),
        connector.WithResp(resp),
        connector.WithHeader(map[string]string{"page_no": "0", "page_size": "10"}),
    )

Any help would be appreciated, thanks!