active_shipping
active_shipping copied to clipboard
[UPS] Failure: The XML document is well formed but the document is not valid.
Hello everyone!
I have a small problem with "create_shipment" in UPS. Every time when I call function "create_ups_shipment" (by ruby console) return that error:
RuntimeError: Could not obtain shipping label. Failure: The XML document is well formed but the document is not valid.
from /home/wiking/.rvm/gems/ruby-2.1.4/bundler/gems/active_shipping-626d17c779c3/lib/active_shipping/carriers/ups.rb:167:in `rescue in create_shipment'
from /home/wiking/.rvm/gems/ruby-2.1.4/bundler/gems/active_shipping-626d17c779c3/lib/active_shipping/carriers/ups.rb:137:in `create_shipment'
from /home/wiking/magazyny/app/models/delivery.rb:115:in `create_ups_shipment'
from (irb):27
This is body of create_ups_shipment function:
def create_ups_shipment
packages = [ActiveShipping::Package.new( 1000, [20,20,20])]
origin = ActiveShipping::Location.new(
:name => "Test",
:contact_name => "TEST",
:telephone => "+48123123123",
:email => "[email protected]",
:country => 'PL',
:city => 'Krakow',
:street => 'Makowa 14',
:addr2 => "",
:postal_code => '30650'
)
destination = ActiveShipping::Location.new(
:name => "Test test",
:contact_name => "Test sp. z o.o.",
:telephone => "+48123123123",
:email => "[email protected]",
:country => 'PL',
:city => 'Poznan',
:street => 'Warszawska 14',
:addr2 => "",
:postal_code => '61113'
)
ups = ActiveShipping::UPS.new(:login => '[my_acount_number]', :password => '[password]', :key => '[UPS_key]', :test => true)
response = ups.create_shipment(
origin,
destination,
packages,
{
:service_code => '11',
:test => true,
}
)
return response
end
In the other hand, when I use function ups.find_rates(origin, destination, packages, :options => {:test => true})
instead of create_shipment
works well. What did I do wrong? Where I can find XML document generated in create_shipment
?
The real bug here is the error message, try the suggestion in https://github.com/Shopify/active_shipping/issues/247 and see that it works. You need to include your origin account info.
destination = ActiveShipping::Location.new(
:name => "Test test",
:contact_name => "Test sp. z o.o.",
:telephone => "+48123123123",
:email => "[email protected]",
:country => 'PL',
:city => 'Poznan',
:address1 => 'Warszawska 14',
:postal_code => '61113'
)
your request should look like this. It is missing the address1 field.
It does not work even if I passed origin_account argument.