Edward
Edward

Reputation: 7424

How to select category of Bing News Results?

Hi I am trying to retrieve news(Bing Search API) from a 1 of the 8 categories Bing offers.

Check Documentation Here.

According to the documentation it should take in a string with one of the values listed in the page above. But everytime I apply it:

request.Query = "Football";
request.Sources = new SourceType[] { SourceType.News };
request.News.Category = "rt_ScienceAndTechnology";//Error comes here

This returns a "null reference exception". Any replies and suggestions would be greatly appreciated.

Upvotes: 0

Views: 708

Answers (1)

Divi
Divi

Reputation: 7701

I think you need to initialise request.News before setting Request.News.Category like this

request.News = new NewsRequest();

taken from here: http://msdn.microsoft.com/en-us/library/dd251024.aspx

Upvotes: 2

Related Questions