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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

"We cannot convert a value of type Record to type Text" when making rest api call

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}
        ]]
    )

 

2 REPLIES 2
lbendlin
Super User
Super User

You put the headers and Query portions in the wrong place.  See example 2 Web.Contents - PowerQuery M | Microsoft Learn

Anonymous
Not applicable

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. 

jdalevem19_0-1701940242615.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Kudoed Authors