Search code examples
jsonapipowerbipowerquerym

Power Query M - Expression Error - list to text


I'm doing a API request using Web.Contents. I submit a dynamic access token, which I get from a function.

let
Source = 
Json.Document(
    Web.Contents(
            {"https://api-url.com/endpoint/id"}, 
            [Headers=[Authorization="Bearer "& GetToken()]]))

in  Source

This works in all of my other instances, but for some reason I get an error with a specific endpoint, to which I submit a id. The error is:

Expression.Error: We cannot convert a value of type List to type Text. Details: Value=[List] Type=[Type]

I have checked the documentation for the API, and the response is composed of the following

id -  Id of the device
lastServicedDate - The last time the service was done.
trip -
total -
stateLastUpdated - the timestamp of the state.

Previous assistance have informed me that I need to expand the list, but I cannot seem to make this work.

Any assistance is highly appreciated. Thank you.


Solution

  • You are supplying a list to Web.Contents instead of text. {} denotes a list. Remove your braces:

    Web.Contents(
            "https://api-url.com/endpoint/id", 
            [Headers=[Authorization="Bearer "& GetToken()]])