Edward
Edward

Reputation: 7424

Bing API ".Count" property not working?

I have been trying to bring back 20 results of images using the Bing API. Here's the code:

SearchRequest request = new SearchRequest();
request.AppId = APPID;
request.Query = HttpUtility.HtmlEncode(searchQuery);
request.Sources = new SourceType[] { SourceType.Image };
request.Image = new ImageRequest();
request.Image.Count = 20;
request.Image.Filters = new string[1] { "Size:Medium" };

Now everything on here works, including the Image.Filters property. Just not the Count property. Is there a known bug or am I just missing something here?

Upvotes: 1

Views: 524

Answers (1)

Bala R
Bala R

Reputation: 108937

I'm not sure really sure about this but I think you are missing setting CountSpecified property. Try this

request.Image = new ImageRequest();
request.Image.Offset = 0;
request.Image.Count = 20;
request.Image.CountSpecified = true;
request.Image.Filters = new string[1] { "Size:Medium" };

Upvotes: 2

Related Questions