Invalid Key error using .NET

Hello: I am just getting started with the API and I am stuck. I am using the .NET helper library and am getting this error when trying to query a contact:

InfusionSoft.InfusionSoftException: ‘Server returned a fault exception: [2] [InvalidKey]Invalid Key’

Here is my code:
public bool Connect(string email)
{
const string application = “ab9999”;
const string apiKey = “aa9m7ya9wc9999999999999”;

        var customer = new Customer(application, apiKey);
        var client = customer.Connect();

        ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

        //Find contacts dotnet style
        var contacts = client.ContactService.FindByEmail(email, p => p.Include(c => c.Id)    <-- ERROR HERE
                                                                      .Include(c => c.Email));

        //Find contact vanilla api style
        var contacts2 = client.ContactService.FindByEmail(email, new[] { "Id", "Email" });

        return true;
    }

Any ideas would be appreciated.

Regards,
Mark

Is that apikey a legacy key (generated in your app) or an oauth client secret?

Bradley:

Thanks for the quick response. The apikey that I am using is the “Key” under the “API Keys” on the page “https://keys.developer.keap.com/my-apps/c8f1fc7d-…”

I am using “ab349” for “application” and the “Key” for “apiKey”

 var customer = new Customer(application, apiKey);

If you can point me to a working .NET sample (C#), that would be very helpful.

And one thing that I don’t understand is, what is the connection between the app that I created and my company’s InfusionSoft instance, which is “ab349”? In other words, I created a developer account and created an app. It seems like there must be somewhere where you say that you give permission for the app to connect to ab349, but I don’t see that.

Regards,

Mark

So the key you are using is an oauth secret then. I don’t think the .NET SDK works with OAuth.

So what key to I use with .NET? Do you have any .NET sample code?

Thanks,
Mark

I have resolved my issue by getting OAuth working.
Thanks.

1 Like