Skip to content

Failed to Serialize Templates #7

@sirchristian

Description

@sirchristian

Trying to call:

var response = await CourierClient.Templates.ListAsync(new ListTemplatesRequest());

I get an error message: Courier.Client.Core.CourierException: Failed to deserialize response

I've tracked this down to (for my response) two issues:

  • The tags are not expecting the data components
  • The channels had errors when there were multiple options.

Here is the full JSON response that fails serialization

{
  "paging": {
    "more": false
  },
  "results": [
    {
      "created_at": 1744135324035,
      "id": "ABCDEFGID1",
      "routing": {
        "channels": [
          "email"
        ],
        "method": "single"
      },
      "topic_id": "ABCDEFGID2",
      "tags": {
        "data": [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ]
      },
      "title": "Account Request Submission",
      "updated_at": 1744135324035
    },
    {
      "created_at": 1744135337838,
      "id": "ABCDEFGID3",
      "routing": {
        "channels": [
          "inbox",
          {
            "channels": [
              "push"
            ],
            "method": "single"
          }
        ],
        "method": "all"
      },
      "topic_id": "",
      "tags": {
        "data": [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ]
      },
      "title": "My First Notification",
      "updated_at": 1744135337838
    },
    {
      "created_at": 1744135331799,
      "id": "ABCDEFGID4",
      "routing": {
        "channels": [
          "email"
        ],
        "method": "single"
      },
      "topic_id": "ABCDEFGID5",
      "tags": {
        "data": [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ]
      },
      "title": "Reset Password",
      "updated_at": 1744135331799
    },
    {
      "created_at": 1744135334866,
      "id": "ABCDEFGID6",
      "routing": {
        "channels": [],
        "method": "single"
      },
      "topic_id": "",
      "tags": {
        "data": [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ]
      },
      "title": "Untitled Notification",
      "updated_at": 1744135334866
    }
  ]
}

and here is JSON that serializes successfully:

{
  "paging": {
    "more": false
  },
  "results": [
    {
      "created_at": 1744135324035,
      "id": "ABCDEFGID1",
      "routing": {
        "channels": [
          "email"
        ],
        "method": "single"
      },
      "topic_id": "ABCDEFGID2",
      "tags": [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ],
      "title": "Account Request Submission",
      "updated_at": 1744135324035
    },
    {
      "created_at": 1744135337838,
      "id": "ABCDEFGID3",
      "routing": {
        "channels": [
          "inbox",
          "push"
        ],
        "method": "all"
      },
      "topic_id": "",
      "tags": 
        [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ],
      "title": "My First Notification",
      "updated_at": 1744135337838
    },
    {
      "created_at": 1744135331799,
      "id": "ABCDEFGID4",
      "routing": {
        "channels": [
          "email"
        ],
        "method": "single"
      },
      "topic_id": "ABCDEFGID5",
      "tags": 
        [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ],
      "title": "Reset Password",
      "updated_at": 1744135331799
    },
    {
      "created_at": 1744135334866,
      "id": "ABCDEFGID6",
      "routing": {
        "channels": [],
        "method": "single"
      },
      "topic_id": "",
      "tags": 
        [
          {
            "id": "120a8e8b-cbaa-44f7-899f-15af56e37349",
            "name": "test"
          }
        ],
      "title": "Untitled Notification",
      "updated_at": 1744135334866
    }
  ]
}

The diff of the JSON can be viewed here: https://www.diffchecker.com/UIwYW4EY/
I also put together a fiddle that can be use to reproduce: https://dotnetfiddle.net/aFLvlC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions