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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SeanSmithy
Regular Visitor

Expression.Error: We cannot convert a value of type Record to type Function.

Hi,

I'm having an issue utilising an API call

The API requires a Token for each request.

I am able to generate the token via this:

 

() =>
let
    url = "http://iserver.x.x:8081/api/token",
    defaultOptions = [
    Content = Text.ToBinary(""),
    Headers = 
        [
           #"Accept" = "application/json",
           #"Content-Type"="application/json;charset=UTF-8",
           #"Authorization"= Text.Combine({"Basic ", Binary.ToText(Text.ToBinary("username:password"),0)})
        ]
    ],

    Token = Json.Document(Web.Contents(url, defaultOptions))
in
    Token

I've used a function so that it can be used in multiple API calls for different data, the first of these is:

 

let
    GetToken = Function.Invoke(iServerGetToken(),null) as text,
    Source = Json.Document(Web.Contents("http://iserver.x.x:8081/api/item?$filter=Type%20eq%20'Business%20actor'&$expand=Attributes(%24select%3DOwner)", [Headers=[Authorization="Bearer "&GetToken]])),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"iServerId", "Name", "Type", "Library", "Description", "ApprovalStatus", "CheckedOutBy", "IsLocked", "VersionNumber", "CreatedBy", "DateCreated", "ModifiedBy", "DateModified"}, {"Column1.iServerId", "Column1.Name", "Column1.Type", "Column1.Library", "Column1.Description", "Column1.ApprovalStatus", "Column1.CheckedOutBy", "Column1.IsLocked", "Column1.VersionNumber", "Column1.CreatedBy", "Column1.DateCreated", "Column1.ModifiedBy", "Column1.DateModified"})
in
    #"Expanded Column1"

 I am getting the following error from the bolded line.

Expression.Error: We cannot convert the value "OMciXKG3iGWA4CzxI4rP..." to type Function.
Details:
    Value=OMciXKG3iGWA4CzxI4rPgYKAQLxHKLNebFdCSFrdIAGltUa94MevrQT03ZjW6mWP
    Type=Type

I've done a good deal of searching but can't seem to find a solution.

I'm not sure this is the most appropriate way of going about things either.

 

Any help would be much appreciated.

 

Thanks

 

 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @SeanSmithy 

Please check if below posts could help.

https://community.powerbi.com/t5/Desktop/Create-tables-based-on-all-Query-Parameters/td-p/345947

https://community.powerbi.com/t5/Desktop/Expression-Error-We-cannot-convert-a-value-of-type-Record-t...

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-cherch-msft
Employee
Employee

Hi @SeanSmithy 

Please check if below posts could help.

https://community.powerbi.com/t5/Desktop/Create-tables-based-on-all-Query-Parameters/td-p/345947

https://community.powerbi.com/t5/Desktop/Expression-Error-We-cannot-convert-a-value-of-type-Record-t...

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.