0

I am trying to automate the extraction of data from Xero into my azure db, and have set up the authentication flow to get and refresh tokens via the key vault etc.

However when it comes to calling various API's via a web activity, I run into issues if trying to use the "If-Modified-Since" header. The xero endpoint simply returns an error as below

enter image description here

But when I remove the If-Modified-Since header, everything works fine. I have also tested the url in Postman and it works fine.

I have tried multiple date formats, utcnow(), getpastdate(), wrapping it all in a string etc etc, and they all fail. I know it will be something simple, but cant work it out!

Below is the call i am making

{
    "url": "https://api.xero.com/api.xro/2.0/Invoices?includeArchived=false&unitdp=2&Page=1",
    "method": "GET",
    "headers": {
        "Authorization": "Bearer xxxx",
        "xero-tenant-id": "xxx",
        "If-Modified-Since": "2021-06-01"
    }
}
  • 1
    It looks to me that the error is raised from the Xero API. Have you tried to send the `If-Modified-Since` header in `yyyy-mm-ddThhss` format as suggested in the [official xero documentation](https://developer.xero.com/documentation/api/accounting/invoices/#overview)? – ray Jul 30 '21 at 12:19
  • Hi Ray, yes I have. I have tried about 10 different formats, and they all work from postman fine. It’s just when called from adf that it fails. Also if I use the format suggested in their docs as verbatim, it produces an error as mm is minutes not month, but I know what they are meaning – user2301960 Jul 30 '21 at 19:27
  • Are you getting same error message after using "2021-06-01T00:00:00" ? – NiharikaMoola-MT Jul 31 '21 at 08:38
  • yes same error message – user2301960 Jul 31 '21 at 09:45

2 Answers2

0

From here:

the only thing that seems to be working is Tue, 12 Jun 2018 11:55:14 GMT as implemented here https://github.com/freakboy3742/pyxero/blob/master/xero/basemanager.py#L292-L297

The Python format string they use is:

%a, %d %b %Y %H:%M:%S GMT

Hopefully that gives you a good example to follow and try even if you have to translate to another expression language.

GregGalloway
  • 11,355
  • 3
  • 16
  • 47
0

Thank You Greg for pointing me in the right direction. I had come across that post, but assumed as the Xero staff had replied, saying that they accept many formats, and it was an old post, it was no longer relevant! The working code i have in adf is

@concat(getPastTime(1,'Day','ddd, dd MMM yyyy hh:mm:ss'),' GMT')