Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

We cannot convert "Accountsync" to type record

Hello everyone,

 

I get this error in this code:

 

let
source = Web.Contents("https://localhost:44346/WeatherForecast/TableList"),
json = Json.Document(Text.FromBinary(source)),
convertToTable = Table.FromList(json, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
columnNames = Record.FieldNames(Table.FirstValue(convertToTable)),
ExpandedColumn1 = Table.ExpandRecordColumn(convertToTable, "Column1", columnNames),
selectColumn = Table.Column(ExpandedColumn1, columnNames{0})
in
selectColumn;

 

This is the data in "source = Web.Contents("https://localhost:44346/WeatherForecast/TableList":

 

[  "AccountSync",  "AggregateState",  "BatchQueue",  "BatchSchedule",  "Binaries",  "BinaryStoreVersion",  "CategoryRiskTotals",  "ClientEvents",  "ClientEventStoreLastEvents",  "Departments",  "Logs",  "MultiSelect",  "Organizations",  "PitStopDayTotals",  "PitStopMonthTotals",  "ProjectionBuilderShard",  "ProjectionBuilderVersion",  "ProjectionStoreVersion",  "QuestionRiskTotals",  "RiskTotals",  "SitStandDayTotals",  "SitStandMonthTotals",  "Streams",  "StreamStoreVersion",  "Surveys",  "SurveyTemplates",  "SurveyUsers",  "UserDepartments",  "UserQuestionRisks",  "UserRiskTotals",  "Users"
]

 But when I get data from "source = Web.Contents("https://localhost:44346/WeatherForecast/" it works perfectly fine, which contains the data:

 

[  {
    "date": "2021-11-19T14:34:51.8028071+01:00",    "temperatureC": 1,    "temperatureF": 33,    "summary": "Freezing"
  },
  {
    "date": "2021-11-20T14:34:51.8033779+01:00",    "temperatureC": 21,    "temperatureF": 69,    "summary": "Cool"
  },
  {
    "date": "2021-11-21T14:34:51.8033806+01:00",    "temperatureC": -13,    "temperatureF": 9,    "summary": "Hot"
  },
  {
    "date": "2021-11-22T14:34:51.803381+01:00",    "temperatureC": 40,    "temperatureF": 103,    "summary": "Warm"
  },
  {
    "date": "2021-11-23T14:34:51.8033812+01:00",    "temperatureC": 20,    "temperatureF": 67,    "summary": "Cool"
  }
]

 

Do I need to change the Splitter.SplitByNothing() parameter? If yes, what do I need to change? If no, what else do I have to change in the code?

 

Thank you.

3 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion
    let
        Source = "[  {#(cr)#(lf)    ""date"": ""2021-11-19T14:34:51.8028071+01:00"",    ""temperatureC"": 1,    ""temperatureF"": 33,    ""summary"": ""Freezing""#(cr)#(lf)  },#(cr)#(lf)  {#(cr)#(lf)    ""date"": ""2021-11-20T14:34:51.8033779+01:00"",    ""temperatureC"": 21,    ""temperatureF"": 69,    ""summary"": ""Cool""#(cr)#(lf)  },#(cr)#(lf)  {#(cr)#(lf)    ""date"": ""2021-11-21T14:34:51.8033806+01:00"",    ""temperatureC"": -13,    ""temperatureF"": 9,    ""summary"": ""Hot""#(cr)#(lf)  },#(cr)#(lf)  {#(cr)#(lf)    ""date"": ""2021-11-22T14:34:51.803381+01:00"",    ""temperatureC"": 40,    ""temperatureF"": 103,    ""summary"": ""Warm""#(cr)#(lf)  },#(cr)#(lf)  {#(cr)#(lf)    ""date"": ""2021-11-23T14:34:51.8033812+01:00"",    ""temperatureC"": 20,    ""temperatureF"": 67,    ""summary"": ""Cool""#(cr)#(lf)  }#(cr)#(lf)]",
        #"Parse Json" = Json.Document(Source),
        Display = Table.FromRecords(#"Parse Json")
    in
        Display

    • Anonymous's avatar
      Anonymous
      Not applicable

      how about the data that contains in "source = Web.Contents("https://localhost:44346/WeatherForecast/TableList

       

      which is 

      [  "AccountSync",  "AggregateState",  "BatchQueue",  "BatchSchedule",  "Binaries",  "BinaryStoreVersion",  "CategoryRiskTotals",  "ClientEvents",  "ClientEventStoreLastEvents",  "Departments",  "Logs",  "MultiSelect",  "Organizations",  "PitStopDayTotals",  "PitStopMonthTotals",  "ProjectionBuilderShard",  "ProjectionBuilderVersion",  "ProjectionStoreVersion",  "QuestionRiskTotals",  "RiskTotals",  "SitStandDayTotals",  "SitStandMonthTotals",  "Streams",  "StreamStoreVersion",  "Surveys",  "SurveyTemplates",  "SurveyUsers",  "UserDepartments",  "UserQuestionRisks",  "UserRiskTotals",  "Users"
      ]
      • v-jingzhang's avatar
        v-jingzhang
        Community Support

        Hi Anonymous 

         

        Try this code. You can transpose it to a row if needed. 

        let
            Source = "[  ""AccountSync"",  ""AggregateState"",  ""BatchQueue"",  ""BatchSchedule"",  ""Binaries"",  ""BinaryStoreVersion"",  ""CategoryRiskTotals"",  ""ClientEvents"",  ""ClientEventStoreLastEvents"",  ""Departments"",  ""Logs"",  ""MultiSelect"",  ""Organizations"",  ""PitStopDayTotals"",  ""PitStopMonthTotals"",  ""ProjectionBuilderShard"",  ""ProjectionBuilderVersion"",  ""ProjectionStoreVersion"",  ""QuestionRiskTotals"",  ""RiskTotals"",  ""SitStandDayTotals"",  ""SitStandMonthTotals"",  ""Streams"",  ""StreamStoreVersion"",  ""Surveys"",  ""SurveyTemplates"",  ""SurveyUsers"",  ""UserDepartments"",  ""UserQuestionRisks"",  ""UserRiskTotals"",  ""Users""#(cr)#(lf)]",
            #"Split Text" = Text.Split(Source, ","),
            #"Converted to Table" = Table.FromList(#"Split Text", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
            #"Replaced Value" = Table.ReplaceValue(#"Converted to Table","[","",Replacer.ReplaceText,{"Column1"}),
            #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","]","",Replacer.ReplaceText,{"Column1"}),
            #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","""","",Replacer.ReplaceText,{"Column1"}),
            #"Trimmed Text" = Table.TransformColumns(#"Replaced Value2",{{"Column1", Text.Trim, type text}})
        in
            #"Trimmed Text"

         

        Best Regards,
        Community Support Team _ Jing
        If this post helps, please Accept it as Solution to help other members find it.