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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jmclej
Helper I
Helper I

how to pass json object in URL via a GET parameter ?

Hello,

I have the following code that works fine :

 

= Json.Document(Web.Contents("https://myurl/documents", [Headers=[Authorization="Bearer "&GetToken(),#"profile"="full-access", #"enduser"="enduser"]]))

 

But when I add the parameter "search" that takes some json like this :

 

= Json.Document(Web.Contents("https://myutl/documents?search={"_type":{"$eq":"Document"}}", [Headers=[Authorization="Bearer "&GetToken(),#"profile"="full-access", #"enduser"="enduser"]]))

 

It works fine with Postman but Power Query tells me there is a syntax error under "_type".

I have the same issue when I add this :

 

= Json.Document(Web.Contents("https://myurl/documents?search={
                              "$and": [  
                                        {"_type": {"$eq":"TOTO"}},
                                        {"$or": [
                                                 {"g_service":{"$eq":"FR_Moto"}},
                                                 {"g_service":{"$eq":"FR_Moto2"}},
                                                 {"g_service":{"$eq":"FR_Moto3"}}
                                             ]}
                                     ] 
                              }", [Headers=[Authorization="Bearer "&GetToken(),#"profile"="full-access", #"enduser"="enduser"]]))

 

The syntax error is under the first dollar sign before the and

Is the issue that we must concatenate strings in json differently in PowerQuery ?

1 ACCEPTED SOLUTION

Actually I found out that I need to escape the double quotes by adding another double quote before each ones within the json part

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You need to use "&" to concatenate strings.

 

For example, if _type = "TypeA", then you could write

"https://myutl/documents?search={TypeA}"

as

"https://myutl/documents?search={" & _type & "}"

If you remove the ampersands, then you'll get an error.

Actually I found out that I need to escape the double quotes by adding another double quote before each ones within the json part

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors