Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
THEG72
Helper V
Helper V

Cannot Apply operator Text and List Conversion required? or syntax error with Parameter usages

Hi Community I am trying to paremterise the file path for a json source,

Query which lists path requiredQuery which lists path requiredhe data source for json source.

I have above query which returns a list containing the file path of the data source as follows:

 

I want to insert this query called "URIPathLocation" into the Web.Contents path but i am getting an error stating

Expression.Syntax.Token Literal Expected.

 

= Json.Document(Web.Contents(" & URIPathLocation & "/Contact/Customer/?api-version=v2"))

How do you add a query ouputting a list into text field...is there a conversion required from Type to list

 

 

Originally, I can get the statement to work as follows, where i manually key the first part and then create a SelectCompany query to choose the ID number (that appears after the Accountright folder name above). The select company parameter is where i manually type in the URI d2c78098-1f9c-xxxxxxx etc. which chooses the company file.

 

I originally was using the following command, which works fine...but only gets the URI and not the path...I am sure its a formatting issue !

 

Json.Document(Web.Contents("http://localhost:8080/AccountRight/" & SelectCompany & "/Contact/Supplier/?api-version=v2"))

 

 ==================

Update !

 

It seems the main issue is when you put the text in a query that outputs a list you get an error .

 

Expression.Error: We cannot apply operator & to types Text and List.
Details:
Operator=&
Left=http://localhost:8080/AccountRight/
Right=List

 

When you create a parameter with a text List of values the expression works with out an issue but its not dynamic.

 

Is there a way to convert the query that outputs a list to a text string that will be accepted by the command below

Json.Document(Web.Contents(

 

1 ACCEPTED SOLUTION

Your formula is passing a static string:

Json.Document(Web.Contents("URIPath&/Contact/Supplier/?api-version=v2"))

and I believe that you're going after something like:

Json.Document(Web.Contents(Text.From(URIPath)&"/Contact/Supplier/?api-version=v2"))

View solution in original post

7 REPLIES 7
v-xjiin-msft
Solution Sage
Solution Sage

Hi @THEG72,

 

In your scenario, what will Web.Contents() return without Json.Document?

 

Web.Contents("http://localhost:8080/AccountRight/" & SelectCompany & "/Contact/Supplier/?api-version=v2")

Thanks,
Xi Jin.

It returns the object, then you right click it and return the output to a Json format to get the original code shown below.

 

Object.PNG

 

= Json.Document(Web.Contents(DataLocation & SelectCompanyURI & "/Contact/Supplier/?api-version=v2"))

I have the following Parameters defined:

DataLocation "http://localhost:8080/AccountRight/"  (Text Based List of Values Manually entered)

SelectCompanyURI  "d2c78098-1f9c-4334-aee9-27349b3ed6a4'" (Text Based List of Values manually entered)

 

The Datalocation api endpoint return the path required for each company file resource when you initially browse the list, convert it to a table and you can see the path required for the Web Contents code.

Object2.PNG

 

If i select the path and either Drill Down or Add as A query, how can i add this to the web.contents code line? I think I am missing some quotes maybe?


The code below returns an error, I assume i have the syntax incorrect

DataFormat.Error: Invalid URI: The hostname could not be parsed. Details: URIPath&/Contact/Supplier/?api-version=v2

 

Json.Document(Web.Contents("URIPath&/Contact/Supplier/?api-version=v2"))

This line does work

http://localhost:8080/AccountRight/d2c78098-1f9c-4334-aee9-27349b3ed6a4/Contact/Supplier/?api-version=v2

 

 

URI Path http://localhost:8080/AccountRight/d2c78098-1f9c-4334-aee9-27349b3ed6a4

Object3.PNG

 

 

Thanks

 

 

Your formula is passing a static string:

Json.Document(Web.Contents("URIPath&/Contact/Supplier/?api-version=v2"))

and I believe that you're going after something like:

Json.Document(Web.Contents(Text.From(URIPath)&"/Contact/Supplier/?api-version=v2"))
Anonymous
Not applicable


M language - Web.Content error : &amp

Hello,
It’s been 2 days I’m blocked, I can’t find the answers à forums.
My formula M langage is Web.Contents(« http://...&... »&[IDMaster]& « ....&... ») as Binary
This gives me an error message : Operator=&amp and replaces the url ...&... to ...&amp....
My goal is to view the images from that Dynamic URL using power query, power pivot and then power view.
It work with static url but not with a dynamic one
I’ve tried to add Text.From but I get the same error
Thank you in advance for you help
Claire

@Anonymous

 

Hi, where are your quotes? you need to break up your URL with quotes for all text items in your URL.

 

If you post the full URL without parameters that might help see the problem...but for example, the statement should be similar to:

 

Web.Contents("http:/myweb/" & IDMASTER & PARAMETER2) . Also ensure your parameters are setup as text.

 

 

 

 

 

 

Anonymous
Not applicable

Hello THEG72,

 

I found the solution with the help of Mickael.

I needed to declare the filed IDMASTER as a string.

So the right code is : Web.contents("http://...."Text.From([IDMASTER])&"....jpg")

 

Thank you for your reply

@Anonymous

 

Glad you got it solved..Yes the URL has to be all text.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.