Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetBody() does not support array of models #27

Closed
guohuang opened this issue Apr 30, 2016 · 9 comments
Closed

SetBody() does not support array of models #27

guohuang opened this issue Apr 30, 2016 · 9 comments
Assignees

Comments

@guohuang
Copy link

guohuang commented Apr 30, 2016

Hi
I am a team member of Swagger CodeGen, we use the resty API, we recently ran into issue when setting body with an array of models, is it a known issue that resty does not allow passing array of objects in the body? below is the test exception:

--- FAIL: TestCreateUsersWithArrayInput (0.00s)
panic: interface conversion: interface is *[]petstore.User, not []uint8 [recovered]
    panic: interface conversion: interface is *[]petstore.User, not []uint8

goroutine 18 [running]:
testing.tRunner.func1(0xc8200f6090)
    /usr/local/go/src/testing/testing.go:450 +0x171
github.com/go-resty/resty.DetectContentType(0x2e9320, 0xc8200fe140, 0x0, 0x0)
    /Users/xx/go/src/github.com/go-resty/resty/client.go:780 +0xd6
github.com/go-resty/resty.handleRequestBody(0xc8200bc000, 0xc82010a000, 0x0, 0x0)
    /Users/xx/go/src/github.com/go-resty/resty/middleware.go:295 +0xc4
github.com/go-resty/resty.parseRequestBody(0xc8200bc000, 0xc82010a000, 0x0, 0x0)
    /Users/xx/go/src/github.com/go-resty/resty/middleware.go:107 +0x245
github.com/go-resty/resty.(*Client).execute(0xc8200bc000, 0xc82010a000, 0x0, 0x0, 0x0)
    /Users/xx/go/src/github.com/go-resty/resty/client.go:579 +0xc7
github.com/go-resty/resty.(*Request).Execute(0xc82010a000, 0x40ab28, 0x4, 0xc8200f2240, 0x32, 0x4, 0x0, 0x0)
    /Users/xx/go/src/github.com/go-resty/resty/request.go:394 +0x105
github.com/go-resty/resty.(*Request).Post(0xc82010a000, 0xc8200f2240, 0x32, 0x4

FYI, with the same code, single object works perfectly.

@jeevatkm jeevatkm self-assigned this Apr 30, 2016
@jeevatkm
Copy link
Member

Thanks for notifying, I will have a look.

@jeevatkm
Copy link
Member

I have verified. Yes, Slice is not yet supported in the implementation.

Now I'm adding support.

@jeevatkm
Copy link
Member

I have added a support. Please try it out and let me know.

@guohuang
Copy link
Author

guohuang commented May 1, 2016

thanks for the quick response, i don't see any PR for this fix, where do i obtain the changes?

@jeevatkm
Copy link
Member

jeevatkm commented May 1, 2016

v0.7 is on master, please take an update. After v0.7 release, it will accessible via go get gopkg.in/resty.v0

@guohuang
Copy link
Author

guohuang commented May 1, 2016

sorry, i have a dump question, if i reference this github.com/go-resty/resty that means i am running your master which is v0.7 right? it didn't work.

@jeevatkm
Copy link
Member

jeevatkm commented May 1, 2016

May or may not be. I have pushed changes today. So please run this for update

go get -u github.com/go-resty/resty

@guohuang
Copy link
Author

guohuang commented May 1, 2016

yes! that seems fixed the issue and my integration tests passed! thank you for fixing it so quickly!

@jeevatkm
Copy link
Member

jeevatkm commented May 2, 2016

Thanks for confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants