Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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()]])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading