GetStream / stream-swift

Swift client for Stream API
https://getstream.io
BSD 3-Clause "New" or "Revised" License
35 stars 26 forks source link

Expected to decode Dictionary<String, Any> but found a string/data instead. #19

Closed jriosdev closed 4 years ago

jriosdev commented 4 years ago

What did you do?

while activity fetching

self.timelineFeed?.get(enrich: true, pagination: .limit(limit) + .offset(offset), ranking: nil, includeReactions: .all, completion: { feedsResults in do{ self.timelinePosts = try feedsResults.get().results } catch { } })

What did you expect to happen?

What happened instead?

getting JSON decoding error: The data couldn’t be read because it isn’t in the correct format.. Data: 5901 bytes ▿ jsonDecode : 3 elements

GetStream Environment

GetStream version:2.2.1 Xcode version:11 Swift version:5 Platform(s) running GetStream:iOS macOS version running Xcode:10.15

Additional context

the error happening inside func parse<T: Decodable>(_ callbackQueue: DispatchQueue, _ completion: @escaping CompletionObjects<T>) { parse(block: { let moyaResponse = try get() var response = try JSONDecoder.default.decode(Response<T>.self, from: moyaResponse.data) if let next = response.next, case .none = next { response.next = nil } callbackQueue.async { completion(.success(response)) } }, catch: { error in callbackQueue.async { completion(.failure(error)) } }) }

b-onc commented 4 years ago

Hey @jriosdev ,

Can you enable and post logs, with Client.config = .init(apiKey: "...", appId: "...", logsEnabled: true)

jriosdev commented 4 years ago

already enabled, the activity result array is printing but the closure FlatFeed.get() return error
"The data couldn’t be read because it isn’t in the correct format."

buh commented 4 years ago

Hi @jriosdev Can you show your Activity type that you use in your timelineFeed? So, basically you use enrichment (enrich: true) and Activity by default use a User as an actor. The error occurs because the JSON data has a string instead of a user JSON for the actor field. Can you show the response from logs?

jriosdev commented 4 years ago

thank u fixed

SRReddy411 commented 8 months ago

@jriosdev how you resolve the above issue i am also facing same but i have try many ways still i am getting same error. thank you