Reputation: 2833
I'm trying to only return images that are Style:Photo and Aspect:Tall.
I can only seem to search for one ImageFilters parameter, like this:
https://api.datamarket.azure.com/Bing/Search/Image?Query='Houses'&$format=JSON&ImageFilters='Style:Photo'&Market='en-us'
The important part:
&ImageFilters='Style:Photo'
If I try to add another one, like this:
ImageFilters='Style:Photo'+'Aspect:Tall'
I get this error:
Parameter: ImageFilters has an invalid pattern of characters
Any ideas?
Upvotes: 2
Views: 2516
Reputation: 10891
This is old, but I had a similar problem which I solved. One problem is that
ImageFilters='Style:Photo'+'Aspect:Tall'
should be ImageFilters='Style:Photo+Aspect:Tall'
, so quoting the whole value, not the individual parameters. The other nonobvious thing here is replacement. This was successfully implemented in a python repo at https://github.com/xthepoet/pyBingSearchAPI. Part of the code:
request = string.replace(request, "'", '%27')
request = string.replace(request, '"', '%27')
request = string.replace(request, '+', '%2b')
request = string.replace(request, ' ', '%20')
request = string.replace(request, ':', '%3a')
This should give the idea!
Upvotes: 1
Reputation: 19154
if ImageFilters='Style:Photo+Size:Small+Aspect:Tall' not work then try to change + sign to %2B
ImageFilters='Style:Photo%2BSize:Small%2BAspect:Tall'
it work for me.
and if you use BingSearchContainer.cs there is one another problem you can't use + sign or %2B the solution is to replace
query = query.AddQueryOption("ImageFilters", string.Concat("\'",
System.Uri.EscapeDataString(ImageFilters),
"\'"));
with
query = query.AddQueryOption("ImageFilters", string.Concat("\'",
ImageFilters,
"\'"));
Upvotes: 3
Reputation: 20556
I just tried the following query with multiple Image Filter directly at Bing Search API Dataset which worked correctly with my subscription:
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27justin%20biber%27&ImageFilters=%27Style%3aPhoto%2bSize%3aSmall%2bAspect%3aTall%27&$top=50&$format=Atom
equivalent to as below:
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query='justin biber'&ImageFilters='Style:Photo+Size:Small+Aspect:Tall'&$top=50&$format=Atom
So if you try putting whole ImageFilter into one single quote as ImageFilters='Style:Photo+Size:Small+Aspect:Tall' and it should work.
Upvotes: 4