Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

Google Script - Signature Invalid - On Complex Queries

Started by Pantelis Zirinis -   in API Authentication

Hello Xero Community,

I am trying to get invoices from Xero to Google Sheets. I have managed the following:

- Get Invoices without any filtering
- Get Invoices with simple filters, like status=paid

I cannot get the following:

- Invoices with Status=Paid,Draft
- Invoices using the where parameter, example where=AccountCode==201
- Combination of the above

The error i am getting is "oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature"

So the problem is with the way the request is signed. I read most of the discussions on this forum and most of the are related to simple queries and I could not find one that had the was using the where keyword.

You can find my code:
This code is provided by the developer community - Xero does not warrant it in any way

Any help will be highly appreciated.
Hi. For me the statuses=paid also not working. could you pl share the getAuthHeader function (after you remove your keys etc.,)

David Crosta  

plain get works and also post/put works. but get with any query parameters is not.

good that status=paid is working for you. i would like to know what you have done diff

David Crosta  

My signature base is as follows

var signatureBase = method + "&"
+ encodeURIComponent(URL) + "&" + encodeURIComponent(param) + "&"
+ encodeURIComponent("oauth_consumer_key=" + CONSUMER_KEY +
"&oauth_nonce=" + oauth_nonce + "&oauth_signature_method=RSA-SHA1&oauth_timestamp=" +
oauth_timestamp + "&oauth_token=" + CONSUMER_KEY + "&oauth_version=1.0")

var URL = 'https://api.xero.com/api.xro/2.0/Invoices'
var param= "Statuses=Paid"

David Crosta  

the following works. Xero has made it super complicated to make a simple query

This code is provided by the developer community - Xero does not warrant it in any way

Pantelis Zirinis