Option Syntax for OData.Feed in PowerQuery

Technical post – for those who need to add options / parameters to their OData feeds in PowerQuery, syntax help is a little thin in the official documentation.

So for those moving beyond the basic connection of

OData.Feed(“http://services.odata.org/Northwind/Northwind.svc”)

If you want to add headers, then do this:

OData.Feed(“http://services.odata.org/Northwind/Northwind.svc”,[Headers=”yourstuffhere“])

Noting that the escape for a double quote is another double quote in your headers string.

If you want to use a boolean option, such as EnableBatch, then do this:

OData.Feed(“http://services.odata.org/Northwind/Northwind.svc”,null,[EnableBatch=false])

Note the use of the plain null with no surrounding quotes if there’s no 2nd parameter value being provided.

Similarly for numeric parameters:

OData.Feed(“http://services.odata.org/Northwind/Northwind.svc”,null,[MaxUriLength=200])

However, Timeout needs to be expressed as a Duration type – so you need to do this manipulation:

OData.Feed(“http://services.odata.org/Northwind/Northwind.svc”,null,[Timeout=Duration.FromText(“00:30″)])

I have done more fun things that try to work out this syntax – I hope this saves you some time!

Read More