Forum Discussion
Fabi66
3 years agoRegular Visitor
Power BI Expression.Error: We cannot convert a value of type Record to type Type. Details: Value=[Re
I get this error in Power BI: Expression.Error: We cannot convert a value of type Record to type Type. Details: Value=[Record] Type=[Type] When I try to use an existing column to query...
- 3 years ago
You could do it like this:
_BaseUri = "https://my.website.com/rest/api/candidates", //_RelativeUrl = , #"InvokeAPI" = Table.AddColumn(#"Removed Columns", "Results", each Json.Document( Web.Contents( _BaseUri, [ //RelativePath = _RelativeUrl, Headers=["Bearer xxxMyTokenxxx", #"Content-Type"="application/json"], Query=[CandidateId=[CandidateId]] ] ) ) )
jennratten
Super User
3 years agoThis is a Table.AddColumn function, so the highlighted portion of your script refers to the argument in the syntax that is looking for the column type, but instead of the type, such as type text, Int64.Type, etc, it is being fed a record. You should replace this with 'type text'.
Table.AddColumn(table as table, newColumnName as text, columnGenerator as function, optional columnType as nullable type) as table
Fabi66
3 years agoRegular Visitor
I tried a couple of things but I guess I don't know how to do what you suggest.
I need a column creating the Rest API call (APIQuery) which has to have header information.
Then I'm using a second custom column to display the results of the API call
#" InvokeAPI" = Table.AddColumn(AddAPIQuery, "APIResponse", each Json.Document(Web.Contents([APIQuery]))
- jennratten3 years ago
Super User
You could do it like this:
_BaseUri = "https://my.website.com/rest/api/candidates", //_RelativeUrl = , #"InvokeAPI" = Table.AddColumn(#"Removed Columns", "Results", each Json.Document( Web.Contents( _BaseUri, [ //RelativePath = _RelativeUrl, Headers=["Bearer xxxMyTokenxxx", #"Content-Type"="application/json"], Query=[CandidateId=[CandidateId]] ] ) ) )- Fabi663 years agoRegular Visitor
Finally got it to work using
#"Add APIQuery" = Table.AddColumn(#"Removed Columns", "APIQuery", each Json.Document(Web.Contents( "https://www.xxx/rest/api/candidates/" & Text.From([CandidateId]) & "/?Fields=LastName&Custom=Source", [Headers=[Authorization="Bearer ***Token***", #"Content-Type"="application/json"]] ) ) )Thank you for your help!