After successfully establishing OAuth2 connection to Xero, call to https://api.xero.com/connections is giving only the id, tenant id and type.
How to get the name (display name) of the connections?
Tried calling Organizations API. It does not work in OAuth2
var url = "https://api.xero.com/connections";
//var response = service.fetch(url, {
var response = UrlFetchApp.fetch(url, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + service.getAccessToken(),
},
muteHttpExceptions : true
});
There is no way of getting connection names and showing it to end-user to choose. (It makes no sense to ask the user to choose from the list of cryptic ids).
You should retrieve each organisation from the /organisation endpoint, with the appropriate tenantId as the value in the xero-tenant-id header:
https://api.xero.com/api.xro/2.0/organisation
This works with both OAuth1.0a and OAuth2 (note the 's' rather than the 'z' in the endpoint).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With