Forum Discussion
Apply filters on REST API JSON POST request
- 1 year ago
Ok i've figured why i had this problem, my segment was set to "one selection" so there was always an item selected, the problem was the api downloaded the report with this selcection, then tried to filter it. i just had to uncheck "only one selection", uncheck everything, save the report, then i could filter my report!
Hi,lbendlin ,thanks for your concern about this issue.
Your answer is excellent!
And I would like to share some additional solutions below.
Hello,Jdrien .I am glad to help you.
Here's how I tested your code.
{
"format": "PDF",
"powerBIReportConfiguration": {
"page": [
{
"pageName": "8e0816bfd0860b75b040"
}
],
"filter": {
"$schema": "http://www.powerbi.com/product/schema#basic",
"target": {
"table": "data_refreshTest",
"column": "animal"
},
"operator": "eq",
"values": ["dog"],
"filterType": 1
}
}
}
According to your description, you mentioned that the API commands can be executed normally, but the filters don't seem to work.
According to the parameter list on the official website, there is a filters parameter in the request, so I think there may be a problem with the content of the request parameter (i.e. the content of the filters) in the body of your request. The filters were not successfully passed into the api, causing this problem.
In the request, you need to pay attention to the various escapes in the request code to make sure that the parameters are passed correctly, and that there are no duplicates or missing symbols.
API:
Reports - Export To File
Reports - Export To File - REST API (Power BI Power BI REST APIs) | Microsoft Learn
About the parameters in report
URL:
Filter a report using query string parameters in the URL - Power BI | Microsoft Learn
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hello! thx for this answer!
i managed to pass the filter on the testpage,
this code:
}
does the trick, guess the way i wrote 95 was my mistake...
i now have a filtered pdf.
But I'm afraid i'm not done yet, the real page i need to filter got tablenames and column names with special caracters, i understand thats why it didnt worked as intended.
Table: Default_1 filtre Gauche
Column: Associé.
....how do i have to encode this to make it work?