crowdin / crowdin-api-client-dotnet

.NET client library for Crowdin API
https://www.nuget.org/packages/Crowdin.Api/
MIT License
52 stars 27 forks source link

Webhook.AddWebhook endpoint response serialization error #76

Closed duyguyildirantekin closed 2 years ago

duyguyildirantekin commented 2 years ago

When calling Webhooks.AddWebhook, I'm getting the following error:

Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

When I checked webhook via UI, the Webhook integration was there. The endpoint creates the webhook but cannot serialize the response. there are two properties which are headers and payload, those properties are tiring to cast to a string array but they are objects.

Related documentation is here

For reference, this is the response I got from the server:

{
  "data": {
    "id": 37,
    "projectId": 15,
    "name": "Backend-Integration",
    "url": "https://test.com/apiservice/translation/file-translated",
    "events": [
      "file.translated"
    ],
    "headers": {
      "auth": "token"
    },
    "payload": {
      "file.translated": {
        "eventType": "{{event}}",
        "projectId": "{{projectId}}",
        "fileId": "{{fileId}}",
        "targetLanguageId": "{{targetLanguageId}}"
      }
    },
    "isActive": true,
    "batchingEnabled": false,
    "requestType": "POST",
    "contentType": "application/json",
    "createdAt": "2022-09-19T17:22:23+03:00",
    "updatedAt": "2022-09-19T17:22:23+03:00"
  }
}

this is my pr request if you interested