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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors