The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello guys,
I have a variable "Id" that I am passing in a payload as shown below. "Id" is a string value like "LASST390000000000003". If I hardcode it, it works but once I pass it in as a variable it fails to work. I will appreciate some help here.
</
let
url = "https://api.bls.gov/publicAPI/v1/timeseries/data/",
Id = Locations[Location]{0},
body = "{""seriesid"":"& Id &",""startyear"":""2017"", ""endyear"":""2022""}", ---------Does not work
body = "{""seriesid"": [""LASST390000000000003""],""startyear"":""2017"", ""endyear"":""2022""}", --------Works
Source = Json.Document(
Web.Contents(
url,
[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
)
)
>
Solved! Go to Solution.
Hi Vijay_A_Verma, thanks for your input. Unfortunatey that couldn't pass in the Id as expected. Howerver, I cracked it following my reference to this resource:
The solution is:
Id = Text.Combine({"[""",Locations[Location]{0},"""]"},""), ----- Crazy string concatenation here
body = "{""seriesid"":"&Id&",""startyear"":""2017"", ""endyear"":""2022""}", ----referencing it here
Use this for body
body = "{""seriesid"":[""&id&""], ""startyear"":""2010"", ""endyear"":""2012""}"
Hi Vijay_A_Verma, thanks for your input. Unfortunatey that couldn't pass in the Id as expected. Howerver, I cracked it following my reference to this resource:
The solution is:
Id = Text.Combine({"[""",Locations[Location]{0},"""]"},""), ----- Crazy string concatenation here
body = "{""seriesid"":"&Id&",""startyear"":""2017"", ""endyear"":""2022""}", ----referencing it here