We have created a demo company and got the Client id and client secret id. We have generated the Auth code using postman tool. We are trying to further hit the other Invoice related APIs like 'create contact', 'invoice' etc.
We have tried calling other APIs (create invoice, contact etc) from Xero API Explorer. We have successfully done that, In API Explorer there are by default authorization code and Tenant id.
But we are not able to get the tenant id from our Demo company of Xero portal.
Please help us to get the tenant id ??
Loading

Sachin SinghPosted Jan 3, 2024, 6:24 AM
You can use the below code
Jayraj ChhayaPosted Jan 3, 2024, 5:47 AM
To retrieve the tenant ID for your demo company in the Xero portal, you can follow these steps:
Make a GET request to the
/connectionsendpoint of the Xero API using the authorization code you obtained from Postman. This endpoint will provide you with a list of connections associated with your account.Look for the connection that corresponds to your demo company. Each connection will have a unique
tenantIdproperty.Retrieve the
tenantIdvalue from the connection object. This is your tenant ID.Here's an example of how you can achieve this using the Xero API SDK in Python:
By following these steps and making the appropriate API calls, you should be able to retrieve the tenant ID for your demo company in the Xero portal.