.netwebhooksssi

Error WebHook by Trinsic API (former Streetcred)


Basic .net core web application throws error while receiving a POST-request (webhook) from TrinsicAPI.

ERROR:

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Bad chunk size data.

The definition of the WebHook can be found here: https://docs.trinsic.id/docs/webhooks-1

And the WebHook-Receiver looks like this:

[DisableRequestSizeLimit]
        [HttpPost]
        public async Task<ActionResult> Post([FromBody] WHPayloadModel payload)
        {
            // Do cool stuff
            // dummy Async method
            var test = await _client.ListWebhooksAsync();
            return Ok();
        }
public class WHPayloadModel
    {
        public enum WHMessage_Type
        {
            [EnumMember]
            new_connection,
            [EnumMember]
            credential_request,
            [EnumMember]
            verification,
            [EnumMember]
            new_inbox_Message
        }

        [DataMember]
        public String Message_Type { get; set; }

        [JsonProperty(PropertyName = "object_id")]
        public String Object_id { get; set; }

        [JsonProperty(PropertyName = "data")]
        public Dictionary<String, String> Data { get; set; } = new Dictionary<String, String>();
    }

And even if I try to catch the request via dynamic object like this - it still throws the same error:

[HttpPost]
        public async Task<ActionResult> Post([FromBody] dynamic payload)
        {
            // Do cool stuff
            // dummy Async method
            var test = await _client.ListWebhooksAsync();
            return Ok();
        }

The error stays the same for different types of project Blazor project, or WebAPI.

> fail:
> Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
>       An unhandled exception has occurred while executing the request. **Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Bad
> chunk size data.**    at
> Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason
> reason)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.CalculateChunkSize(Int32
> extraHexDigit, Int32 currentParsedSize)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ParseChunkedPrefix(ReadOnlySequence`1&
> buffer, SequencePosition& consumed, SequencePosition& examined)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.Read(ReadOnlySequence`1
> readableBuffer, PipeWriter writableBuffer, SequencePosition& consumed,
> SequencePosition& examined)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.PumpAsync()
> at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()    at
> System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)    at
> System.IO.Pipelines.Pipe.ReadAsync(CancellationToken token)    at
> System.IO.Pipelines.Pipe.DefaultPipeReader.ReadAsync(CancellationToken
> cancellationToken)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ChunkedEncodingMessageBody.ReadAsyncInternal(CancellationToken
> cancellationToken)    at
> Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1
> buffer, CancellationToken cancellationToken)    at
> System.Text.Json.JsonSerializer.ReadAsync[TValue](Stream utf8Json,
> Type returnType, JsonSerializerOptions options, CancellationToken
> cancellationToken)    at
> Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext
> context, Encoding encoding)    at
> Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext
> context, Encoding encoding)    at
> Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext
> bindingContext)    at
> Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext
> actionContext, IModelBinder modelBinder, IValueProvider valueProvider,
> ParameterDescriptor parameter, ModelMetadata metadata, Object value)  
> at
> Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
> --- End of stack trace from previous location where exception was thrown ---    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker
> invoker, Task lastTask, State next, Scope scope, Object state, Boolean
> isCompleted)    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker
> invoker, Task lastTask, State next, Scope scope, Object state, Boolean
> isCompleted)    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed
> context)    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State&
> next, Scope& scope, Object& state, Boolean& isCompleted)    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
> --- End of stack trace from previous location where exception was thrown ---    at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker
> invoker, Task task, IDisposable scope)    at
> Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint
> endpoint, Task requestTask, ILogger logger)    at
> Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext
> context)    at
> Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext
> context)    at
> Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext
> context)    at
> Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext
> context)    at
> Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext
> httpContext)    at
> Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext
> httpContext)    at
> Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext
> context)

The Post request works using Postman API tool. Therefore I did host the development application using the conveyor.cloud to access it from WAN.

This is the definition of the POSTMAN POST request

https://MyProjectName.conveyor.cloud/api/WebHook

Definition of the body:

    {
    "message_type": "new_connection",
    "object_id": "00000000",
    "data": {
        "param1": "value1",
        "param2": "value2"
    }
}

enter image description here

So the error seems to come directly from the trinsic API.

The trigger for the WebHook is when a new_connection is created.

Cheers!


Solution

  • The issue came from the VSStudio extension service conveyour.cloud.

    https://conveyor.cloud/Home/How_To_Install

    The issue should be resolved soon, they are working on a fix.