cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
iBusinessBI
Resolver II
Resolver II

Web.Contents Query Parameters - prevent from encoding

I am trying to run an API request with Web.Contents.
It works fine when I paste the whole request in a base URL, but when I break it to parts, the Query Parameters are sent after encoding. 
Query = [
q="search",
search="(status:(values:List(ACTIVE)))"
],

Instead of this correct parameter

search=(status:(values:List(ACTIVE)))  
The following is what gets requested and I get 400 Bad request:
search=%28status%3A%28values%3AList%28ACTIVE%29%29%29 
How can I prevent it from encoding?
6 REPLIES 6
iBusinessBI
Resolver II
Resolver II

This works fine:

Json.Document(Web.Contents("https://api.linkedin.com/rest/",
[
RelativePath = "adAccounts/11111111/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))",

Headers=[
**some headers**
]
]))

But this doesn't:
Json.Document(Web.Contents("https://api.linkedin.com/rest/",
[
RelativePath = "adAccounts/11111111/adCampaigns",
Query = [
q="search",
search="(status:(values:List(ACTIVE)))"
],
Headers=[
**some headers**
]
]))

 

I get the following error:
DataSource.Error: Web.Contents failed to get contents from 'https://api.linkedin.com/rest/adAccounts/11111111/adCampaigns?q=search&search=%28status%3A%28values%3AList%28ACTIVE%29%29%29' (400): Bad Request

It is clear that the problem is that this gets encoded automatically when it is in the "Query=[]" section:

search=%28status%3A%28values%3AList%28ACTIVE%29%29%29

then it doesn't work. I tried to pass the encodied part as Base url and it gives the same error. So the endpoint can only accept unencoded text.

I somehow need it NOT to be encoded when included in Query=[], so it stays the same:

(status:(values:List(ACTIVE)))
Please help

So the endpoint can only accept unencoded text.

Bit of an oversight on the endpoint's side, eh?

 

As long as you can hide the dynamic part of the URL in the RelativePath attribute you should be able to refresh this data source in the service.  Not pretty, but if it works ¯\_ (ツ)_/¯

lbendlin
Super User
Super User

please show the URL that works

It does work, but it makes me put all the Query parameters in the Relative Path, and I prefer in the Query = [] clause.
Maybe there is some way to tell it not to encode....

If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com/?forum=2d80fd4a-16cb-4189-896b-e0dac5e08b41

Yes, but first I want to make sure this option does/doesn't exist today.

Maybe you can do it?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors