v0.2.2 broken on novu api 0.18.0 upgrade
toddb opened this issue · comments
The latest version SaaS version of Novu (cloud), and i'm using this package v0.2.2
The error i'm getting upon deserialising the response is
Refit.ApiException: An error occured deserializing the response.
---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Novu.DTO.AdditionalDataDto]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'data._id', line 1, position 15.
but the part i find odd is this one Path 'data._id', line 1, position 15.
. It seems that the entire response of the GetSubscriber
is now wrapped in a data
property (similarly what is happening with the CreateTopic
endpoint where a TopicCreateResponseDto
is returned )
In summary seems that the response contract has changed for the Subscriber endpoints and now the actual response object is wrapped in a Data
prop
So instead of returning a SubscriberDto
should be returning it in an envelope, something like
class Foo {
[JsonProperty("data")]
public SubscriberDto Data { get; set; }
}
[Get("/subscribers/{id}")]
Task<Foo> GetSubscriber(string id);
[Post("/subscribers")]
Task<Foo> CreateSubscriber([Body] CreateSubscriberDto dto);
Originally posted by @joaonlforte in #46 (comment)
@joaonlforte So, I have found where the API is versioned. It is on the health-check
resource. Looking at the source, it is not an external API resource (so you can't use the ApiKey token) and need to hijack your JWT. I did that by copying a request and then changing it. I don't get why this isn't at the root of the API.
~ curl 'http://localhost:3000/v1/health-check' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NGM5YTc1ZmUxOGQ3ZjJjYjk3ODcxNjMiLCJmaXJzdE5hbWUiOiJ0IiwibGFzdE5hbWUiOiJub3Z1IiwiZW1haWwiOiJ0K25vdnUtbG9jYWwuZGV2QHBpY21pLmlvIiwib3JnYW5pemF0aW9uSWQiOiI2NGM5YTc3NWUxOGQ3ZjJjYjk3ODcxNzAiLCJyb2xlcyI6WyJhZG1pbiJdLCJlbnZpcm9ubWVudElkIjoiNjRjOWE3NzZlMThkN2YyY2I5Nzg3MTc2IiwiaWF0IjoxNjkyNTc0NjU1LCJleHAiOjE2OTUxNjY2NTUsImlzcyI6Im5vdnVfYXBpIn0.9-iVXXsWKfR7DaBojrhlMtRjMBjXSAJGiZXt0GIxZYU' \
--compressed
{"status":"error","info":{"db":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"}},"error":{"inMemory":{"status":"down"}},"details":{"db":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"},"inMemory":{"status":"down"}}}%
Originally posted by @toddb in #46 (comment)
So the answer in production is: 0.18.0
~ curl 'https://api.novu.co/v1/health-check' \
-H 'authority: api.novu.co' \
-H 'accept: application/json, text/plain, */*' \
-H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8,mi;q=0.7' \
-H 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6I ...-bfSmesKN2w' \
--compressed
{"data":{"status":"ok","info":{"db":{"status":"up"},"inMemory":{"status":"up"},"apiVersion":{"version":"0.18.0","status":"up"},"triggerQueue":{"status":"up"},"cacheService":{"status":"up"}},"error":{},"details":{"db":{"status":"up"},"inMemory":{"status":"up"},"apiVersion":{"version":"0.18.0","status":"up"},"triggerQueue":{"status":"up"},"cacheService":{"status":"up"}}}}% ➜ ~
Originally posted by @toddb in #46 (comment)