cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dkpcr5
Frequent Visitor

Cannot convert to type List

I think my M needs a syntax adjustment, but I'm not sure where or how.

 

Here's the M:

let
Source = Json.Document(Web.Contents("https://apiURL/ACCOUNT_INFO?$top=2000",
    [Headers=
        [   
            #"ocp-apim-subscription-key" = Text.Combine({Subscription}),
            #"integrator-key" = Text.Combine({Integrator}),
            #"x-universal-refresh-token" = Text.Combine({Refresh}),
            #"x-universal-directive" = "x",
            #"respos-cache" = "false"
            ]]
        )
    ),
#"Converted to Table" = Record.ToTable(Source),
Value = #"Converted to Table"{0}[Value],
Custom1 = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(Custom1, "Column1",
    {"Account_ID", "Account_Title"}
    )
 
in

    #"Expanded Column1"

Here's the error:

 

Expression.Error: We cannot convert the value "https://host/$metada..." to type List.
Details:
Value=https://host/$metadata#ACCOUNT_INFO
Type=[Type]

 

When I'm told to "Go To Error," it seems the offending part is: 

Custom1 = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

 

Any assistance would be appreciated. Thanks!

1 ACCEPTED SOLUTION
dkpcr5
Frequent Visitor

Closing this thread since I've resolved the issue.

 

Turns out, the problem was not with the syntax of the M, but with the fact that the API wasn't returning any records due to session expiration. After renewing the session, the API once again returned data, and the error went away without any change to the original M.

 

Sincere kudos to @watkinnc for the assist.

View solution in original post

3 REPLIES 3
watkinnc
Solution Sage
Solution Sage

I would try replacing:

 

Value = #"Converted to Table"{0}[Value],

With:

 

NewValue = #"Converted to Table"[Value],

 And then your next line would be:

 

Table.FromList(NewValue,...etc


--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
dkpcr5
Frequent Visitor

Thanks, but not sure I'm completely following. You're saying, just remove the {0}?

 

When I do, I get the results below:

cannotConvert.PNG

The error for cell 1 under "Account_UID" is shown in the image. 

The error for cell 2 under "Account_UID" is different, and says:

 

Expression.Error: We cannot convert a value of type List to type Record.
Details:
Value=[List]
Type=[Type]

dkpcr5
Frequent Visitor

Closing this thread since I've resolved the issue.

 

Turns out, the problem was not with the syntax of the M, but with the fact that the API wasn't returning any records due to session expiration. After renewing the session, the API once again returned data, and the error went away without any change to the original M.

 

Sincere kudos to @watkinnc for the assist.

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors