Passing an array #1

Closed
cimm opened this Issue Jun 21, 2012 · 9 comments

Comments

Projects
None yet
3 participants

cimm commented Jun 21, 2012

Is there a way to pass an array to the API? I have this endpoint that accepts a JSON array but I can't seem to get it defined in the API Taster DSL.

post '/profile', { :profile => { :friend_ids => [1, 4, 5] } }

The array defined in the example breaks the DSL, the endpoint doesn't work in the API Taster UI. I tried passing the array as a string and it shows up in the interface but it submits the value as a string off course so the backend rejects it.

Thanks!

Owner

fredwu commented Jun 21, 2012

Oops, that's an oversight. I'll get it fixed tomorrow. :)

cimm commented Jun 21, 2012

Whow, you didn't have to respond that fast. :) Great gem by the way, will make our lives a lot easier, thanks for that.

fredwu closed this in e4211e6 Jun 22, 2012

It would be great to configure nested arrays to build requests like this

action = add_to_cart
item[0][name] = flower
item[0][price] = 4.95
item[1][name] = pot
item[1][price] = 2.45

Really miss that ability

Owner

fredwu commented Jul 3, 2012

Thanks, just noticed there's a bug in handling nested arrays so I'm reopening this ticket.

fredwu reopened this Jul 3, 2012

fredwu closed this in aa6c853 Jul 3, 2012

Owner

fredwu commented Jul 3, 2012

@Magnolia-Fan It should be fixed on master now. Can you try:

:items => [
  { :name => 'flower', :price => '4.95' },
  { :name => 'pot', :price => '2.45' }
]

Thanks for the quick fix! Now it works, but still not how I expected.
This code passes a hash inside hash, not an array of hashes. But i still can fix it like this:

"items[]" => [
  { :name => 'flower', :price => '4.95' }
]

Btw, a clone button that duplicates a hash inside this array would be great.

Owner

fredwu commented Jul 3, 2012

Hmm, I see, I'll investigate in the next day or two. Thanks!

fredwu reopened this Jul 3, 2012

Owner

fredwu commented Jul 4, 2012

@Magnolia-Fan Hi could you please try again with the new commit? :)

Owner

fredwu commented Jul 9, 2012

Closing this for now, if you still have issues please reply back. :)

fredwu closed this Jul 9, 2012

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