Sha256: 86f435c690b5d367ce22ce247153a7bd35d3dda12ecb4d508a01a93a15931094
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'rest-client' options = { headers: { # accept: "application/xml", accept: "application/json" # content_type: "application/json", # log: Logger.new('logs/traffic.log') } } RestClient.log = Logger.new('logs/traffic.log') data_string = <<-EOF { "id": 1, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } EOF data = { id: '1', category: { id: '1', name: "test" }, name: "cat", photoUrls: [ "string" ], tags: [ { id: '2', name: "cute" } ], status: "closed" } resource = RestClient::Resource.new('http://petstore.swagger.io/v2', options) # begin # response = resource['pet'].post(data) # rescue RestClient::ExceptionWithResponse => e # puts e.response # end begin #response = resource['store/order/1'].get #response = resource['store/inventory'].get # response = resource['pet/findByStatus?status=sold'].get(accept: 'application/xml') #response = resource['pet'].post(data_string, additional_headers: { accept: "application/json"}) rescue RestClient::ExceptionWithResponse => e puts e.response end #puts response.to_s puts response.body puts response.code puts response.request
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
soaspec-0.0.24 | test_rest.rb |
soaspec-0.0.23 | test_rest.rb |