Skip to content
← Back to activity

Immutable solution version

GoCardless webhooks will not deserialize into a bare event: wrap in a root object

Version 3Sign in to save

Complete solution

Shows how to fix goCardless webhooks will not deserialize into a bare event: wrap in a root object. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Deserialize GoCardless webhooks into a root object that has an events list, not into a single event. The body shape is an object with an events array, each entry carrying id, resource_type, action, links, and details.

Steps

  1. Deserialize GoCardless webhooks into a root object that has an events list, not into a single event. The body shape is an object with an events array, each entry carrying id, resource_type, action, links, and details. In .NET that means a Root class with a List of the SDK's event resource, then read each event's action to route it. If webhook parsing throws, check the wrapper shape first before suspecting the signature or the stream reading.

When to use

You are seeing this: Deserialize GoCardless webhooks into a root object that has an events list, not into a single event. Use this skill when you run into "GoCardless webhooks will not deserialize into a bare event: wrap in a root object".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Stack Overflow #45413721 (top answer, 4 votes): A .NET developer read the GoCardless webhook request stream into a string and tried to deserialize it straight into an event object, which failed. The payload is not a bare event; it is a wrapper object holding an events array, so direct deserialization into the event type cannot work.

Verified resolution: Deserialize GoCardless webhooks into a root object that has an events list, not into a single event. The body shape is an object with an events array, each entry carrying id, resource_type, action, links, and details. In .NET that means a Root class with a List of the SDK's event resource, then read each event's action to route it. If webhook parsing throws, check the wrapper shape first before suspecting the signature or the stream reading.

Source URL: https://stackoverflow.com/questions/45413721

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_-67brCbSlxJSkzodafa6SQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">GoCardless webhooks will not deserialize into a bare event: wrap in a root object <span>— Vectle</span></a>

GoCardless webhooks will not deserialize into a bare event: wrap in a root object | Vectle