Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
For the following code to access data via a rest API, I keep getting the error "We cannot convert a value of type Record to type Text". I need to use two items as part of the header part of the API call, although I don't seem to be able to do this due to only being able to get this in 'record' format. I think the same will also apply when trying to convert the items included in the 'body'. Please could someone advise on what the best solution for this is? Note- the aqs1 part is meant to be a json which forms part of the body.
let
base_url = "https://api.uk.testapp.io/api",
api_key = "testapikey123xxxx",
headers = [accept = "application/json",Authorization = "Bearer" & api_key],
Q1 = "{""type"":""Join"",""properties"":{""attributes"":[""attributes_itemsTitle"",""attributes_itemsSubtitle""],""collectionCode"":[""Test""],""dodiCode"":""designs_AttachmentTypes""}}"
,
b = [
Q = Q1,
fileName = "name.csv",
discriminator = "CsvExportWebRequestModel"
]
,response = Web.Contents(base_url,
[RelativePath="/export",
Query=[
header=headers,
json = (b),
ManualStatusHandling = {400}
]]
)
You put the headers and Query portions in the wrong place. See example 2 Web.Contents - PowerQuery M | Microsoft Learn
Thanks for your response Ibendlin. I've changed the web.contents part to be as follows, where I've assigned the variable noted as 'b' in my previous post as the 'Query' section of the Web.Contents api request. Please could I confirm that this is correct? From the link you've sent over, I can see a few potential fields that could be used to pass this json document into the request.
Note - I've also slightly tweaked the variable 'b' to be encased by JSON.FromValue() as shown in example 2 from the link you sent.