Ruby unirest发送post请求

发送Post json格式数据请求


require 'unirest'
require 'json'
url = 'http://katest.ehuodi.com/ehuodiKAApi/smartStowage/cableOrderGroup/add'
headers = {'cookie':'session_key=4CBC83808CEC45C0BEDE64FEE2874B9C_session_567975613', 'Content-Type':'application/json' }
parameters = {'addressCount':1, 'cableOrderIds':[90945], 'name':'3'}.to_json
response = Unirest.post(url, headers:headers, parameters:parameters)
puts response.body['msg']

发送post form-data请求


require 'unirest'
url = 'http://managementtest.ehuodi.com/ehuodiCrmApi/insurancePolicy/selectListByConditions'
headers = {'cookie':'session_key=681026bd7cea4c76b4bb2a08bc2f58ee_session_16141'}
parameters = {checkStatus:2, pageSize:15, skipCount:0}
response = Unirest.post(url, headers:headers, parameters:parameters)
puts response.body['data']

你可能感兴趣的:(Ruby unirest发送post请求)