-
-
Save oeddyo/14450fbd2b6cd7bc99ad to your computer and use it in GitHub Desktop.
sdfa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post "/retailers/#{retailer_id}/orders", | |
{:order => {:retailer_id => retailer_id, :product_ids_with_quantities => [[2, 1],[2, 1]]}}.to_json, | |
{:Authorization => token} | |
打印params的话 | |
{"order"=>{"retailer_id"=>"1", "product_ids_with_quantities"=>["2", "1", "2", "1"]}, "format"=>:json, "controller"=>"api/v1/orders", "action"=>"create", "retailer_id"=>"1"} |
def raw_post(action, params, body, token)
@request.env['RAW_POST_DATA'] = body
puts params
response = post action, params, {:Authorization => token}
@request.env.delete('RAW_POST_DATA')
response
end
raw_post "/retailers/#{retailer_id}/orders",
{:order => {:retailer_id => retailer_id, :product_ids_with_quantities => [[2, 1],[2, 1]]}}.to_json,
nil,
token
变成
{"{"order":{"retailer_id":1,"product_ids_with_quantities":"=>{"2,1"=>{","=>{"2,1"=>{"}}"=>nil}}}}, "format"=>:json, "controller"=>"api/v1/orders", "action"=>"create", "retailer_id"=>"1"}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
post "/retailers/#{retailer_id}/orders",
{:order => {:retailer_id => retailer_id, :product_ids_with_quantities => [[2, 1],[2, 1]]}},
{:Authorization => token}
gives
打印params的话
{"order"=>{"retailer_id"=>"1", "product_ids_with_quantities"=>["2", "1", "2", "1"]}, "format"=>:json, "controller"=>"api/v1/orders", "action"=>"create", "retailer_id"=>"1"}