Lorenzo Nocentini
Lorenzo Nocentini

Reputation: 1

AD Exchange Seller API .NET

we are trying to set up a C# application that uses google ad exchange seller api, but without success. This is the code used (we saved credentials in a json file):

using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using Google.Apis.AdExchangeSeller.v1_1;

UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
    GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, new[] { AdExchangeSellerService.Scope.AdexchangeSeller }, 
        "user", CancellationToken.None, new FileDataStore("AdexchangeSeller.Auth.Store")).Result;

    AdExchangeSellerService service = new AdExchangeSellerService(new AdExchangeSellerService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "Test108",
    });

    ReportsResource.SavedResource.ListRequest lr = service.Reports.Saved.List();
    AdunitsResource.ListRequest cr = service.Adunits.List("6115701188");
}

The resulting variables however (lr and cr) do not contain any data. I cannot find any example on the web about how to use this client library for .NET, can someone please suggest me what I am doing wrong? Thanks.

Upvotes: 0

Views: 331

Answers (1)

user3592037
user3592037

Reputation: 11

After creating the request, you need to execute the request by calling Execute method:

ReportsResource.SavedResource.ListRequest lr = service.Reports.Saved.List();
Google.Apis.AdExchangeSeller.v1.Data.SavedReports reports = lr.Execute();

The data it self will be stored in the reports var after executing the request

Upvotes: 1

Related Questions