cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SeanSmithy Visitor
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("usernameSmiley Tongueassword"),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

Accepted Solutions
v-cherch-msft Super Contributor
Super Contributor

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

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.
1 REPLY 1
v-cherch-msft Super Contributor
Super Contributor

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

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
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 28 members 843 guests
Please welcome our newest community members: