# Invalid Key error using .NET

**URL:** <https://integration.keap.com/t/invalid-key-error-using-net/75740>\
**Category:** API Q&A\
**Tags:** api\
**Created:** [March 29, 2020, 10:11pm UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740 "2020-03-29T22:11:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Sutton](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Mark\_Sutton](https://integration.keap.com/u/Mark_Sutton)\
**Post date:** [March 29, 2020, 10:11pm UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/1 "2020-03-29T22:11:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bradb](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/bradb/32/13_2.png) [@bradb](https://integration.keap.com/u/bradb)\
**Post date:** [March 30, 2020, 2:44am UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/2 "2020-03-30T02:44:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mark\_Sutton](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Mark\_Sutton](https://integration.keap.com/u/Mark_Sutton)\
**Post date:** [March 30, 2020, 4:49am UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/3 "2020-03-30T04:49:42Z")

</div>

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-](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

---

<div class="post-metadata">

**Author:** ![bradb](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/bradb/32/13_2.png) [@bradb](https://integration.keap.com/u/bradb)\
**Post date:** [March 30, 2020, 5:23am UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/4 "2020-03-30T05:23:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mark\_Sutton](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Mark\_Sutton](https://integration.keap.com/u/Mark_Sutton)\
**Post date:** [March 30, 2020, 3:13pm UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/5 "2020-03-30T15:13:41Z")

</div>

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

Thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![Mark\_Sutton](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@Mark\_Sutton](https://integration.keap.com/u/Mark_Sutton)\
**Post date:** [March 30, 2020, 8:37pm UTC](https://integration.keap.com/t/invalid-key-error-using-net/75740/6 "2020-03-30T20:37:43Z")

</div>

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