当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - How to pass patch http request parameters via HTTParty gem?

问题描述:

I am using the HTTParty gem to make a patch request to update an object via an API call as follows:

params = { first_name: "John"}

@options = {params: params}

@response = HTTParty.patch("http://localhost:3000/1/kites/4", @options)

But on the API side, within the update method that the above PATCH request is supposed to call I only see the following parameters available:

{"format"=>"json",

"controller"=>"api/v1/kites",

"action"=>"update",

"version"=>"1",

"id"=>"4"}

An error message is passed back to the @response for pasrsing.

What happened to first_name and/or how do I call HTTParty.patch appropriately if that is indeed what is causing the loss of the parameters passed to the API?

EDIT:

As it turns out, if I do

@options = {query: params}

that will work but only if I keep a query under a certain size....

分享给朋友:
您可能感兴趣的文章:
随机阅读: