【发布时间】:2018-01-11 15:01:05
【问题描述】:
我正在使用 xeroizer gem,但遇到了一些问题。
这是我的控制器中的内容:
items_found = Item.where(code: codes)
if items_found
xero.Item.batch_save do
binding.pry
items_found.each do |existing_item|
if existing_item.xero_id
item = xero.Item.find(existing_item.xero_id)
item.description = existing_item.description
item.unit_price = existing_item.rate
else
item = xero.Item.first(where: { code: existing_item.code })
item.description = existing_item.description
item.unit_price = existing_item.rate
end
end
end
end
items_found 数组包含所有已存储并存在于 xero 中的项目,我从 codes 的数组中获得。如果存储了xero_id,我会尝试查找Item,但它失败了。
但是,在binding.pry 调用之后,我的代码因此错误而失败
Xeroizer::ApiException - PostDataInvalidException: The element 'CogsAccountCode' was not recognised. Ensure the element name has the correct case and that there are no duplicate elements of the same name.
Generated by the following XML:
<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>14</ErrorNumber>
<Type>PostDataInvalidException</Type>
<Message>The element 'CogsAccountCode' was not recognised. Ensure the element name has the correct case and that there are no duplicate elements of the same name.</Message>
</ApiException>:
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/http.rb:197:in `handle_error!'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/http.rb:116:in `http_request'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/http.rb:41:in `http_post'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/application_http_proxy.rb:24:in `http_post'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/record/base_model.rb:167:in `block (2 levels) in save_records'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/record/base_model.rb:165:in `block in save_records'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/record/base_model.rb:164:in `save_records'
() home/alex/.rvm/gems/ruby-2.3.5/bundler/gems/xeroizer-2d305fbdfdb1/lib/xeroizer/record/base_model.rb:191:in `batch_save'
app/controllers/xero_session_controller.rb:286:in `create_items'
我找到了类似的error
xeroizer gem 文档/代码中没有提到CogsAccountCode。
任何帮助将不胜感激。
【问题讨论】:
标签: ruby-on-rails xero-api xeroizer