Hi!
I'm trying to make an app to download images from Google search queries. And I get the Error [400]: "Request contains an invalid argument." at listRequest.Execute().Items.
Current code:
What I'm doing wrong please?
Thanks.
I'm trying to make an app to download images from Google search queries. And I get the Error [400]: "Request contains an invalid argument." at listRequest.Execute().Items.
Current code:
C#:
using Google.Apis.Customsearch.v1.Data;
using Google.Apis.Customsearch.v1;
using Google.Apis.Services;
using System.Net;
......
......
private void Form1_Load(object sender, EventArgs e){
DownloadGoogleImages("fox mulder", 20, "C:\\", [my apikey], [my Search Engine ID]);
}
public static void DownloadGoogleImages(string query, int numResults, string saveFolderPath, string apiKey, string searchEngineId)
{
var customSearchService =
new CustomsearchService(new BaseClientService.Initializer { ApiKey = apiKey });
var listRequest = customSearchService.Cse.List();
listRequest.Cx = searchEngineId;
listRequest.SearchType = CseResource.ListRequest.SearchTypeEnum.Image;
listRequest.Num = numResults;
listRequest.Start = 1;
listRequest.Q = query;
IList<Result> paging = listRequest.Execute().Items; // RUNTIME ERROR HERE
..........
..........
What I'm doing wrong please?
Thanks.