# Create a C# Webhook for Okta

**URL:** <https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440>\
**Category:** Questions\
**Created:** [March 19, 2021, 6:52pm UTC](https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440 "2021-03-19T18:52:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![userone](https://avatars.discourse-cdn.com/v4/letter/u/848f3c/32.png) [@userone](https://devforum.okta.com/u/userone)\
**Post date:** [March 19, 2021, 6:52pm UTC](https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440/1 "2021-03-19T18:52:23Z")

</div>

Hi everyone,

This question might be too general but I basically want to create a webhook in c# to respond to  
a eventhook in Okta. I understand what needs to be done in Okta (I think) but having trouble getting started on c#. If anyone can help me get started it would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [March 19, 2021, 11:58pm UTC](https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440/2 "2021-03-19T23:58:54Z")

</div>

Hi @userone! Although not specific to C# we do have an example in Node JS - [Build Easy User Sync Webhooks with Okta | Okta Developer](https://developer.okta.com/blog/2020/07/20/easy-user-sync-hooks).

---

<div class="post-metadata">

**Author:** ![kevintparker](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@kevintparker](https://devforum.okta.com/u/kevintparker)\
**Post date:** [March 23, 2021, 7:19pm UTC](https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440/3 "2021-03-23T19:19:30Z")

</div>

I just started looking into eventhooks. I build a web api controller (yeh, kind old tech, but it works)

I only got as far as to save the data sent and write it out. The oktainlinehookheader is a random string value i created and saved in web.config and entered into Okta. The ‘HttpPost’ is what is used, but ‘HttpGet’ is what is used for Okta to verify the code is yours.

Hope this helps.

```
                private string oktaInlineHookHeader = System.Configuration.ConfigurationManager.AppSettings["oktaInlineHookHeader"].ToString();[HttpPost]
    public object Post(HttpRequestMessage request)
    {
        AuthenticationHeaderValue authorization = request.Headers.Authorization;var data = request.Content.ReadAsStringAsync().Result;

        string fn;

        fn = Guid.NewGuid().ToString().Left(5) + "-eventHook.txt";

        
            System.IO.File.WriteAllText(DataFolder + fn, data);

        if (authorization == null || string.IsNullOrEmpty(authorization.Scheme))
        {
           
            return Content(HttpStatusCode.Unauthorized, "Missing credentials");
        }

        if (request.Headers.Contains("Authorization"))
        {
            string a = request.Headers.GetValues("Authorization").First();

            if (a != oktaInlineHookHeader)
            {
                return Content(HttpStatusCode.Unauthorized, "Invalid header");
            }
        }

        JObject o = JObject.Parse(data);

        return Content(HttpStatusCode.OK, "");

    }

    [HttpGet]
    public object Get()
    {
        var re = Request;
        var headers = re.Headers;

        if (headers.Contains("X-Okta-Verification-Challenge"))
        {
            string value = headers.GetValues("X-Okta-Verification-Challenge").First();

            OktaVerify ov = new OktaVerify();
            ov.verification = value;

            return Ok(ov);
        }

        return NotFound();
    }

    public class OktaVerify
    {
        public string verification { get; set; }
    }
```

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [January 27, 2024, 12:05am UTC](https://devforum.okta.com/t/create-a-c-webhook-for-okta/13440/4 "2024-01-27T00:05:37Z")

</div>


