0

I call a controller action "passit" of Rails app A and want to pass an array b to an api update call via an HTTP request using the HTTParty gem patch method:

def passit
  b=[[1,2,3],[4,5,6]]
  params["a"] = b.to_json
  id=5
  @options = {query: params}
  @response = HTTParty.patch("someapi.com/#{id}", @options)
end

The only way I have found to pass b so far so that a value other than nil gets passed to the API is to stringify it via to_json.

Is the only way to pass a nested array via a patch/put/some kind of update request over http is to "stringify" the parameter via JSON or converting it to a string?

1 Answer 1

1

Have a look at Marshal. That allows you to convert objects into byte streams that you can then transfer more easily.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.