saltedge / saltedge-ios-swift

MIT License
10 stars 13 forks source link

The given data was not valid JSON #40

Closed AdAvAn closed 4 years ago

AdAvAn commented 4 years ago

Hey.

When I try to download a list of providers (including fake ones), I get the error "The given data was not valid JSON". Code = 3840

[Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})))]

It looks like there is an error parsing incoming json, can you check your model?

ConstantinKV commented 4 years ago

Hello. Due to some changes in rate limits in our API, your request to providers list can be refused. We are investigating this issue and in short time will send you extra information about those limitations. Thank you.

ConstantinKV commented 4 years ago

@AdAvAn please read next topic https://docs.saltedge.com/general/#rate_limits

AdAvAn commented 4 years ago

@ConstantinKV , thanks for the link, take a note. There is some progress regarding the problem with the performance of saltedge-ios-swift SDK?

ConstantinKV commented 4 years ago

@AdAvAn please explain the problem with the performance of saltedge-ios-swift SDK, to be aligned. Because this issue is related to rate limits applied by Salt Edge API.

AdAvAn commented 4 years ago

I am trying to load a list of providers using the method: getAllProviders (with params: SEProviderParams? = nil, completion: SEHTTPResponse <[SEProvider]>)

My implementation of this request looks like this:

public func getProviders (countryCode: String, includeFake: Bool, completion: @escaping ProvidersResult) {

let params = SEProviderParams (includeFakeProviders: includeFake, includeProviderFields: false)

SERequestManager.shared.getAllProviders (with: params, completion: {response in
switch response {
case .success (let value):
completion (value.data, nil)
Loger.curent.debug ("Received [\ (value.data.count)] providers for count [\ (countryCode)], includeFake: [\ (includeFake)]")
case .failure (let error):
Loger.curent.error (error)
completion ([], error)
}
})
}

Performing this request, with the parameter includeFake = true, I get an error and print it in the console:

[Swift.DecodingError.keyNotFound (CodingKeys (stringValue: "data", intValue: nil), Swift.DecodingError.Context (codingPath: [], debugDescription: "No value associated with key CodingKeys (stringValue: \" data \ ", intValue : nil) (\ "data \"). ", underlyingError: nil))]

I can not go to the next step, because of this error, it was not previously. I execute only this one request, no more.

baller784 commented 4 years ago

@AdAvAn Hello!

Please update Podfile up to the latest version of Salt Edge SDK (3.3.2). We have increased maximum number of items fetched per request and correspondingly decreased request rate.

More information: https://docs.saltedge.com/general/#pagination https://docs.saltedge.com/general/#rate_limits

AdAvAn commented 4 years ago

@baller784, it works - correctly, thanks for the help!