Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Can't convert text value to list

Hi All,


I am trying to loop through my first collum to fill every row in an OData link. see code below:

 

 

 

let
    
    Source = [id],
    
    ProcessItem = (item) =>
        let

            ODataLink = "https://api.api.com/api/example/" & Text.From(item) & "/value",
            
            Result = OData.Feed(ODataLink)
        in
            Result,

    Results = List.Transform(Source, each ProcessItem(_))
in
    Results

 

 

 

However my code brings the following error: Expression.error: Can't convert value "1234567" to type list.

 

My function is returning text so why does List.Transform give me this error?

 

If anyone has suggestions please let me know, thanks in advance!

 

4 Replies

  • pls try this

      Source = {[id]}, // convert to list
        
        ProcessItem = (item) =>
            let
    
                ODataLink = "https://api.api.com/api/example/" & Text.From(item) & "/value",
                
                Result = OData.Feed(ODataLink)
            in
                Result,
    
        Results = List.Transform(Source, each ProcessItem(_))
    in
        Results
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your suggestion, however i now get the following error: The metadata document could not be read from the message content

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

     

    Based on your description, you can try this.

    let
        YourTableName = YourActualTableName, // Replace with your actual table name
        Source = Table.Column(YourTableName, "id"),
        ProcessItem = (item) =>
            let
                ODataLink = "https://api.api.com/api/example/" & Text.From(item) & "/value",
                Result = OData.Feed(ODataLink)
            in
                Result,
        Results = List.Transform(Source, each ProcessItem(_))
    in
        Results

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

    • Anonymous's avatar
      Anonymous
      Not applicable

      This query gives me the error: UnexpectedXmlElement : The schema element 'NavigationProperty' was not expected in the given context. When i manually enter the query with a fixed value it does work. So there must be something with formatting the value?