Open Dongss opened 2 months ago
Describe the bug
Sending request with httpc, with array form ?status=["Processing", "Cancelled"]
?status=["Processing", "Cancelled"]
Server got error:
fullName: `status`, error: `string: `[Processing Cancelled]`, error: `invalid character 'P' looking for beginning of value``
To Reproduce
type MyRequest struct { Status []string `form:"status,optional"` }
code:
req := types.MyRequest{ Status: []string{"Processing", "Cancelled"} } httpc.Do(ctx, "GET", "localhost:80", req)
The error is server side got error:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
More description
The problem seems like happening here: fmt.Sprint(v)
fmt.Sprint(v)
https://github.com/zeromicro/go-zero/blob/d5302f2dbe1ea23812c4775bedcbe6626f7641fb/rest/httpc/requests.go#L60
Use json tag and post json instead.
type MyRequest struct { Status []string `json:"status,optional"` }
Describe the bug
Sending request with httpc, with array form
?status=["Processing", "Cancelled"]
Server got error:
To Reproduce
code:
The error is server side got error:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
More description
The problem seems like happening here:
fmt.Sprint(v)
https://github.com/zeromicro/go-zero/blob/d5302f2dbe1ea23812c4775bedcbe6626f7641fb/rest/httpc/requests.go#L60