API POST with array using HTTP gem

57 views
Skip to first unread message

Brian Watson

unread,
Sep 27, 2017, 3:55:19 PM9/27/17
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API

I'm having trouble with this api and can't seem to get over the hump. Using the HTTP gem. Anyway, I'm having trouble posting an array. everything else is good, I just can't figure out this "itemsarray" in the printaura api found here in the addorder method: PrintAura API

I'm running this:

def self.submitorder   
  req = HTTP.post("https://api.printaura.com/api.php", :json => { 
        :key => APIKEY, 
        :hash => APIHASH, 
        :method => "addorder",
        :businessname => "this is a secret too",
        :businesscontact => "thats a secret",
        :email => "m...@email.com",
        :your_order_id => "1",
        :returnlabel => "FakeAddress",
        :clientname => "ShippingName",
        :address1 => "ShippingAddressLine1",
        :address2 => "ShippingAddressLine2",
        :city => "ShippingCity",
        :state => "ShippingState",
        :zip => "ShippingZip",
        :country => "US",
        :customerphone => "dontcallme",
        :shipping_id => "1",
        :items => [ 
           {
             :product_id => 423,
             :brand_id => 33,
             :color_id => 498,
             :size_id => 4,
             :front_print => 1389517,
             :front_mockup => 1390615,
             :quantity => 1
           }
        ]
}) puts JSON.parse(req) end

And my output is this:

{"status"=>false, "error_code"=>19, "result"=>19, "message"=>"You cannot place an order without items, Please fill the items array with all the required information. Full API documentation can be found at https:/www.printaura.com/api/"}

If someone could look at that and help me out I would forever appreciate it!

Answer on stack and earn some points here

Reply all
Reply to author
Forward
0 new messages