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
googlogmob
Advocate II
Advocate II

Unable to convert a value of type List in the Record Type in Query

Hi

I am trying to get records from а web-service

Using this code I have got an error

 

Unable to convert a value of type List in the Record Type.

http://prntscr.com/drhibr

 

let
    #"campaignsId_List"= Table.FromList(Table.Column(campaigns, "campaignId"), null, {"campaignId"}, null, null),

    Ссылка = "campaigns/statistics/balance?query[campaignId]=PGp8n",

    #"Запрос http" = Table.AddColumn(#"campaignsId_List", "responseJson", each Record.ToTable( Json.Document(Web.Contents(URL & Ссылка & [campaignId], [Headers=[#"X-Auth-Token"="api-key "& Token, #"X-Domain"= Domain , #"Content-Type"="application/json"]]))))
in
    #"Запрос http"

What is а cause of this error?

1 ACCEPTED SOLUTION

Had a closer look at your code and to me it looks as if you need to remove Errors from your column "responseJSON" (check the column -> righclick with mouse -> select "Remove Errors".

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

6 REPLIES 6
ImkeF
Super User
Super User

It could be that the Json.Document doesn't return a record, but a list instead.

Try the expression without the "Record.ToTable"-conversion and check the format of the returned Json.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF, Thank you
This error was because Record.ToTable have gotten null-string
Is there any way to exclude null-records?

Yes, you can use if .. then (for conditions) or try ... otherwise (as the error-handler).

What exactly shall happen: Skip the step & continue with the previous step instead or return a default-value?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImleF, I need use "Skip the step & continue with the previous step"

Here is screen http://prntscr.com/drxkgm

 

Please help add this check to the code

 

let
    #"campaignsId_List"= Table.FromList(Table.Column(campaigns, "campaignId"), null, {"campaignId"}, null, null),

    Ссылка = "campaigns/statistics/balance?query[campaignId]=",

    #"Запрос http" = Table.AddColumn(#"campaignsId_List", "responseJson", each Record.ToTable( Json.Document(Web.Contents(URL & Ссылка & [campaignId], [Headers=[#"X-Auth-Token"="api-key "& Token, #"X-Domain"= Domain , #"Content-Type"="application/json"]]))))
in
    #"Запрос http"

Had a closer look at your code and to me it looks as if you need to remove Errors from your column "responseJSON" (check the column -> righclick with mouse -> select "Remove Errors".

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF, yes, it works!

Thank You 🙂

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.