Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Error: we cannot apply field access to type text.

Hello I got error on this code:

 

 

[DataSource.Kind="Helloworld", Publish="Helloworld.Publish"]
shared Helloworld.Contents = (optional message as text) =>
let  
    endpoint = "https://localhost:44346/WeatherForecast",
    directive= "A",
    cache    = "false",
    keys = endpoint[value],
    command  = Record.FromList({keys}, {"Command"}),
    headers  = Record.FromList({command},{"Headers"}),
    payload  = Json.Document(Web.Contents(endpoint, headers)),
    value = payload[value],
    #"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
   #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table","Column1", headers)
 
in

    #"Expanded Column1";

 

 

the error is: we cannot apply field access to type text.

 

Does anyone know why?

3 Replies

  • Hi Anonymous 

     

    What step causes that error?  It's impossible to test as I don't have access to your endpoint server.

     

    You should be getting more than just that error as there are a few problems with the code.  

     

    In the first line it looks like you are trying to create a record but you haven't given that record a name e.g. NewRecord = [....]

     

    The last line shouldn't end with a semi-colon.

     

    The error message we cannot apply field access to type text. is related to records.  I'd say you are trying to do something with a text value but treating it like it's a record.

     

    Regards

     

    Phil

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Why do you use "endpoint[value]" to define "keys"?

     

    It is needed to connect to endpoint to get the data firstly.

     

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Icey's avatar
      Icey
      Icon for Community Support rankCommunity Support

      Hi Anonymous ,

       

      Any updates?

       

       

      Best Regards,

      Icey