Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
alops1
Frequent Visitor

Call an api with a filter

Hello all colleagues,

I need your help. I am trying to call an api with a filter through power query, but I receive this error.

alops1_0-1747644749323.png

 

I attach the code:

alops1_1-1747644811624.png

What am I doing wrong?

thank you so much

2 ACCEPTED SOLUTIONS

Hi  ,
Thanks for reaching out to the Microsoft fabric community forum.

Try to modify the M query into this 

let
    api = url_getEventPending & apiEvent & "/search",
    token = getTokenData(),
    idValue = "667995612c15a237078c605e",
    fullUrl = api & "?id=" & idValue,
    
    apiResponse = Web.Contents(
        fullUrl,
        [
            Headers = [
                Authorization = token,
                #"Content-Type" = "application/json"
            ]
        ]
    ),
    
    FormatAsJsonQuery = Json.Document(apiResponse)
in
    FormatAsJsonQuery


and check if you are able to bypass the error.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

View solution in original post

MarkLaf
Super User
Super User

The error message is telling you that your Content field value needs to be of type binary, but you are instead supplying an M record. Most likely, you can fix this by wrapping your record in Json.FromValue

 

You can see it in action in example 2 in the MS doc:

https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-2

View solution in original post

8 REPLIES 8
MarkLaf
Super User
Super User

The error message is telling you that your Content field value needs to be of type binary, but you are instead supplying an M record. Most likely, you can fix this by wrapping your record in Json.FromValue

 

You can see it in action in example 2 in the MS doc:

https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-2

v-nmadadi-msft
Community Support
Community Support

Hi @alops1 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked. If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @alops1 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If our responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @alops1 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

v-nmadadi-msft
Community Support
Community Support

Hi @alops1  ,
Thanks for reaching out to the Microsoft fabric community forum.

vnmadadimsft_0-1747664613747.png

 

There may be an extra closing bracket ] in the code that's affecting the syntax and causing the error. Please review the structure carefully, and let us know if the issue persists after correcting it.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

Hi @v-nmadadi-msft ,

thanks a lot for the answer but unfortunately that square bracket closes headers and if I remove it the code goes into error.

Hi @v-nmadadi-msft ,

thanks a lot for the answer but unfortunately that square bracket closes headers and if I remove it the code goes into error.

Hi  ,
Thanks for reaching out to the Microsoft fabric community forum.

Try to modify the M query into this 

let
    api = url_getEventPending & apiEvent & "/search",
    token = getTokenData(),
    idValue = "667995612c15a237078c605e",
    fullUrl = api & "?id=" & idValue,
    
    apiResponse = Web.Contents(
        fullUrl,
        [
            Headers = [
                Authorization = token,
                #"Content-Type" = "application/json"
            ]
        ]
    ),
    
    FormatAsJsonQuery = Json.Document(apiResponse)
in
    FormatAsJsonQuery


and check if you are able to bypass the error.

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors