XeroAPI/xero-ruby

API calls failure

JoeKaldas opened this issue · 3 comments

Hello, so I've successfully integrated the gem with the authentication, refresh and all

However, whenever I try any accounting API, I get the following:

ruby/3.1.0/net/http/header.rb:21:in block in initialize_http_header':`

So the docs actually pass the tenant_id as follow tenant_id = xero_client.last_connection which is a hash while the header is expecting a string

Exception when calling create_bank_transactions:

undefined method strip for {"id"=>"07cd7d0d-040c-4415-9597-1e45d79fe8df", "authEventId"=>"f8e84c02-fae6-4f5c-956d-a86751cada4c", "tenantId"=>"56b172a1-e537-44d4-882b-ff113a9870c6", "tenantType"=>"ORGANISATION", "tenantName"=>"Demo Company (Global)", "createdDateUtc"=>"2022-09-04T13:26:43.6474990", "updatedDateUtc"=>"2022-09-04T13:26:43.6486810"}:Hash

value = value.strip # raise error for invalid byte sequences

So update, for a VERY weird reason
this doesn't work xero.accounting_api.get_contacts(xero.last_connection["tenantId"])
however this doesn't work xero.accounting_api.get_contacts("56b172a1-e537-44d4-882b-ff113a9870c6")

It works if I assign to a variable and then use it but not directly from xero.last_connection["tenantId"]

And they're both the same, check screenshots below

Screen Shot 2022-09-05 at 8 16 57 PM

Screen Shot 2022-09-05 at 8 23 45 PM

Hi @JoeKaldas thanks for this, before I dig further into this, can I ask have you downloaded any of the Xero Ruby sample Apps?
There is a variety and handling of the tenant-id in them :
https://github.com/XeroAPI/xero-ruby#sample-applications

Hi @JoeKaldas there has been no update from you, so please do come back if you still have the issue. Otherwise I'm going to close this one out.