novuhq / novu-kotlin

Kotlin SDK for Novu - The open-source notification infrastructure for engineers. 🚀
MIT License
21 stars 6 forks source link

MarkSubscriberFeed method throws exception #63

Closed lwuethrich-devedis closed 8 months ago

lwuethrich-devedis commented 10 months ago

When calling the Novu#markSubscriberFeed method with a MarkSubscriberFeedAsRequestthe following exception is thrown:

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 10 path $.data
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:395)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:259)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:161)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:266)
    at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)
    at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
    at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)

Code snippet used:

 fun markNotificationAs(user: User, messageId: String, isRead: Boolean) {
        val markRequest = MarkSubscriberFeedAsRequest(
            messageId = messageId,
            mark = Mark(read = isRead, seen = true),
        )
        runBlocking {
            novu.markSubscriberFeed(user.id, markRequest)
        }
    }