Question

Webhook Integration in C#

  • 28 September 2021
  • 1 reply
  • 37 views

Badge

I have implemented webhook for revenuecat  in .net core C#. But for some reason I am getting 400 badrequest with empty response. I am mostly sure that I am not getting the json response in webook through revenuecat for any of the event occurring.
I have also added endpoint on revenue cat webhook with authentication. I have tried several time and as I have not way to test this on local machine. I need help from revenue cat team to provide some reference doc with sample implementation just to get proper json response. Below is the code snippet that I am using to get json response from the webhook endpoint added in revenuecat.

 

 var webHookSecret = _configuration[Constants.RevenueCatWebHookSecret];
                var headerAuthorization = HttpContext.Request.Headers["Authorization"].ToString();

                #region Check authorization
                if (webHookSecret == headerAuthorization)
                {
                    json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
                }
                else
                {
                    _logger.Information($"Un-Authorized token access in revenuecat webhook. Returning BadRequest response.");
                    throw new APIException(HttpStatusCode.Unauthorized, new APIError(_configuration, "InternalServerError"));
                }


1 reply

Badge

I have also tried to show the json in API response to check if we are getting the json from revenuecat or not but still getting an empty response. But for test request the json response shows up correctly. Please check the screenshot below.

Reply