Jump to content

The ultimate community for Ruby on Rails developers.


Photo

How to build correct XML

savon xml

  • Please log in to reply
No replies to this topic

#1 kabanek

kabanek

    Passenger

  • Members
  • 2 posts

Posted 31 May 2014 - 03:26 PM

I want to build request like the below:

http://wklej.org/id/1367146/

Hoverer, I cannot build the XML using Savon. Here is how I do it:

def get_transactions_ids(options = {})
options[:items_id_array] ||= []
options[:user_role] ||= 'seller'
options[:shipment_id_array] ||= []

message = {
session_handle: @session_handle,
items_id_array: WebapiHelper.array_to_items_array(options[:items_id_array]),
user_role: options[:user_role],
shipment_id_array: options[:shipment_id_array],
}

client.call(:do_get_transactions_i_ds, message: message)
end

Here is implementation of WebapiHelper.array_to_items_array function

def self.array_to_items_array (array)

result = []

array.each do |item|
result.push ({:item => item})
end

[result]

end

It produces me the following XML http://wklej.org/id/1367149/ It adds extra tag under tag.







Also tagged with one or more of these keywords: savon, xml

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users