Forum Discussion
TSantoro99
5 years agoNew Member
Escape Special Characters '[' and ']' in API query
I am attempting to setup an API query with relative paths so that it can be run from Power BI (web, not desktop). Unfortunately, the API I am working with uses '[' and ']' as part of its required par...
PhilipTreacy
Super User
5 years agoHi TSantoro99
In Power Query you can escape special characters in strings using their Unicode code e.g. LB = "#(005B)", and in a URL entered into a browser you could use %5B and %5D to replace [and ] but I cannot get this to work with Web.Contents. Any attempt to use special characters, escape sequences or strings gives and error.
So you may have to just rebuild the query to allow for this, like so;
let
Param1 = "q[data_gt]=2019-09-01",
Param2 = "&q[s]=date+desc",
Param3 = "&page=" & page,
FullRequest = "https://secure.fleetio.com/api/v1/?"&Param1&Param2&Param3,
HTTPHeader = [RelativePath="service_entries",
Headers = [#"Authorization"="Token token=""XXXXXXXXXX""", #"Account-Token"="XXXXXX"]],
Source = Json.Document(Web.Contents("https://secure.fleetio.com/api/v1/?"&Param1&Param2&Param3, HTTPHeader))
in
Source
Please note that the value for page is not defined in that query.
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.