Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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 ?
Solved! Go to 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
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