Forum Discussion
Apply filters on REST API JSON POST request
- 2 years 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!
//filter: ["test1group and company/company eq '5'"], // i also used this way
https://learn.microsoft.com/zh-cn/rest/api/power-bi/reports/export-to-file#code-try-0
https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-url-filters
i tried to stringfy the object but still get the same issue and passing something like this "test1group and company/company eq '5'"
if anyone can help i will be appreciative it
thanks
You need to escape spaces in table and column names
- fabyx1 year agoFrequent Visitor
Hallo lbendlin
thank you for getting back to me,
I have different scenarios
1st scenario.
reportLevelFilters: [
{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "test1group%20and%20company",
column: "company",
},
filterType: 1,
operator: "eq",
values: ["5"],
requireSingleSelection: false,
},
],i get this kind of errorPower BI Export Error: {
code: 'InvalidRequest',
message: 'Export report filter with empty string provided'
}2nd scenario is when i use paramaters
reportLevelFilters: [
{ filter: "test1group%20and%20company%2Fcompany%20eq%20'5'" },
],this doesn't show an error, the image is exported but without filter applied
3rd scenario
reportLevelFilters: [
{
filter: {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "test1group%20and%20company",
column: "company",
},
filterType: 1,
operator: "eq",
values: ["5"],
requireSingleSelection: false,
},
},
],when i add filter the response change to this
Power BI Export Error: {
code: 'BadRequest',
message: 'Bad Request',
details: [
{
message: 'Invalid value',
target: 'request.powerBIReportConfiguration.reportLevelFilters[0].filter'
},
{ message: "'request' is a required parameter", target: 'request' }
]
}i am really stuck on this topic, every resources that i can find is suggesting the same thing
i followed this table for escaping the all required characters
if you have ever got this before or anyone here was in the same situation as mine, kindly help out
thanks
Faby
- lbendlin1 year ago
Super User
that's not how you escape spaces.
Filter a report using query string parameters in the URL - Power BI | Microsoft Learn