Note that there are some explanatory texts on larger screens.

plurals
  1. PORestClient strips out the array of hashes parameter with just the last hash?
    primarykey
    data
    text
    <p>I have a condition where i need to pass a parameter as an array of hashes which looks like this:</p> <p>The following is the Rack::Test post method for API call.</p> <pre><code>post "#{url}.json", :api_key =&gt; application.key, :data =&gt; [{"Company"=&gt;"Apple,Inc","Website"=&gt;"Apple.com"},{"Company"=&gt;"Google","Website"=&gt;"google.com"}], :run =&gt; { :title =&gt; "The First Run" } </code></pre> <p>And this is the log of the rails app.</p> <pre><code>Parameters: {"api_key"=&gt;"6a9acb84d0ea625be75e70a1e04d26360606ca5b", "data"=&gt;[{"Company"=&gt;"Apple,Inc", "Website"=&gt;"Apple.com"}, {"Company"=&gt;"Google", "Website"=&gt;"google.com"}], "run"=&gt;{"title"=&gt;"The First Run"}, "line_id"=&gt;"4e018e2c55112729bd00000a"} </code></pre> <p>Now, this is the RestClient post method I'm using to call the API.</p> <pre><code>RestClient.post("/lines/#{@line.id}/runs.json", {:run =&gt; {:title =&gt; @title}, @param_for_input =&gt; @param_data}) </code></pre> <p>And this is the log of the rails app.</p> <pre><code>Parameters: {"run"=&gt;{"title"=&gt;"run name"}, "data"=&gt;{"Company"=&gt;"Google", "Website"=&gt;"google.com"}, "api_key"=&gt;"f488a62d0307e79ec4f1e6131fa220be47e83d44", "line_id"=&gt;"4e018a505511271f82000144"} </code></pre> <p>The difference is in the <code>data</code> parameter. </p> <p>When sending with Rack::Test method, the data is passed as <code>"data"=&gt;[{"Company"=&gt;"Apple,Inc", "Website"=&gt;"Apple.com"}, {"Company"=&gt;"Google", "Website"=&gt;"google.com"}]</code> </p> <p>but via RestClient way, the parameter data array is stripped out and only the last hash is passed as <code>"data"=&gt;{"Company"=&gt;"Google", "Website"=&gt;"google.com"}</code></p> <p>Why the RestClient is stripping out the array of hashes to just a last hash of the array?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload