0

I've got an ASP.Net MVC (Framework version 4.6.2) site where I'm trying to integrate daily expense totals from our Bing Ads campaign through the API.

I've added the package Microsoft.BingAds.SDK through Nuget and written some code against its classes that compiles, so I figured I could fire it up and see what happens.

What happens is this:

Could not find default endpoint element that references contract 'Microsoft.BingAds.V11.Reporting.IReportingService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

The error happens in the constructor of the ReportingServiceClient():

var client = new ReportingServiceClient();

I'm not sure how to proceed. There is indeed no endpoint configured in my .config file. I would have expected Nuget to add necessary config, but there's nothing. I have no idea why it didn't, or what I'm supposed to be adding to my .config.

Menno van den Heuvel
  • 1,851
  • 13
  • 24

1 Answers1

0

Do you have more details e.g., code snippet where you create and use the service client? Are you using A) ReportingServiceManager or B) ServiceClient?

AuthorizationData authorizationData = new AuthorizationData
{
    // By this point OAuthWebAuthCodeGrant already has 
    // access and refresh tokens
    Authentication = OAuthWebAuthCodeGrant,
    DeveloperToken = "DeveloperTokenGoesHere"
};

// Option A: ReportingServiceManager
ReportingServiceManager reportingServiceManager = new ReportingServiceManager(authorizationData);

// Option B: ServiceClient<IReportingService>
ServiceClient<IReportingService> service = new ServiceClient<IReportingService>(authorizationData);

Here is an example web solution from the API Docs. I suggest that you also review this example from GitHub that uses ReportingServiceManager.

Also note that I installed System.ServiceModel.Primitives 4.4.1, System.ServiceModel.Http 4.4.1, and System.ServiceModel.ConfigurationManager 4.4.1 (ran into issues several weeks ago with some other versions) as documented here.

I hope this helps!

Eric Urban
  • 582
  • 2
  • 7
  • I get it at the constructor of the ReportingServiceClient. Did your projects get the proper endpoint in the .config file? – Menno van den Heuvel May 07 '18 at 07:38
  • Turns out my mistake was creating a ReportingServiceClient at all. It sounds like a useful class, but all it does is complain about EndPoints. I think that class should probably have been internal rather than public. – Menno van den Heuvel May 14 '18 at 14:28