App rejection due to JSON parsing

We have uploaded an app to app store, it got rejected 5/6 times as during review they can not interact with API calls, it shows "Network Error". We have verified the test-flight app & found that it is working fine


Only at the time of App store review I got the error "JSON could not be serialized because of error:\nThe data couldn’t be read because it isn’t in the correct format."


I am using Alamofire for API call.


Here is the request parameter which

"requestParameter": {"device_token": "cBXIAfxpEpk:APA91bH8AZYHqMniP5oGNuHT7czD-wHm_ioE-th1_LkN3_w5w_KUa5grT6Ff73D8j9Kn-xONeK4ytT8ZSfVssG9mf4KwJzhY7WdoSxUHxLKNxyGMI0g9ieyuyF25Pi3KwFXDIQmawmow", "time_zone": "America/Los_Angeles", "device_type": "ios", "username": "demo", "password": "password", "location": "37.452728,-121.940140"}




We have checked with backend API log but there is no log fired at that time , So its unable to communicate from mobile with API


Here is my API method

func serviceCall(withPath path:String, withData param:[String:Any], withCompletionHandler completion:@escaping (AnyObject?) -> Void){
    let requestURL = String(format: "%@%@", BaseURL, path)
    let manager = Alamofire.SessionManager.default


    manager.session.configuration.timeoutIntervalForRequest = 40


    manager.request(requestURL, method: .post, parameters: param, encoding: URLEncoding.methodDependent, headers: nil).responseJSON { (responseJson) in
        print("Response 10: \(responseJson)")


        if ((responseJson.result.value != nil)){
           // store details to firebase


        } else {
           // store details to firebase
        }
    }
}



please help me out already rejected by app store for many times 😟



Thank you in advance !!

Only you know what is the correct format. So you are the only one able to understand what is incorrect in the format.


Just you could increase the timeout, in case server is slow to respond ?


Do you get a print for Respoinse ?

print("Response 10: \(responseJson)")


If so, what do you get ?

Additionally, nobody other that you knows what a "log fired" is. Your code doesn't make much sense. If all it does is print a message to the console, it sounds like you don't need it. And finally, your request parameter isn't valid JSON.


Why would you be getting errors during app store review? And is that the extent of the error? It seems like you need more detail than that. Could it be an encoding error judging from what happened to your apparently smart quotes?

Thanks Claude31 for your response


We are speculating the parameter is in correct format because the users from same location(our client) able to do API call successfully and we also hardcoded the parameter and verified, and also verified in REST API. Coming to TimeOut issue, if this will the case then we should get error of timeOut instead of JSON parsing issue, any how we increased the the timeOut to 40s which was previously 10s.


Below is the Response (during app review)

"JSON could not be serialized because of error:\nThe data couldn’t be read because it isn’t in the correct format." which we logged in firebase."


Below is the Response(During our testing whihc is succeeded)

"response": "SUCCESS: {\n \"aws_access_key\" = ***************;\n \"aws_bucket\" = \"project-v2-prod\";\n \"aws_secret_key\" = \"***********\";\n \"created_at\" = \"2017-06-30T06:25:23.221+00:00\";\n \"facebook_id\" = 1212121212121;\n \"firebase_legacy_key\" = *****************;\n \"google_api_key\" = ********************;\n \"google_places_api_key\" = \"************************\";\n id = \"*******-7294-40ea-8041-d0a823e23a52\";\n \"is_active\" = 1;\n \"stripe_publishable_key\" = \"*******************\";\n \"stripe_secret_key\" = \"*********\";\n \"updated_at\" = \"2017-06-30T06:25:23.221+00:00\";\n}

During app review we can't get the console, so we loged the response,parameter and requestURL to a text file by converting all of them to string. We are thinking our parameter is valid because we did check of REST API and also for the code is working with our client from same lcoation.


The thing is our every API call is getting failed during review only. But for us and our testflight users able to do the API calls without any fail. If it is the encoding error then how it's working during testing or for client!!

It is pretty obvious that the parameter is not valid. Otherwise, it would have worked. I don't know the details of your code. All I can tell from here is that you are having problems with strings and unicode. I suggest you take a closer look at that. If you can't successfully log the errors, then you are probably not using the API correctly.

App rejection due to JSON parsing
 
 
Q