I am trying to call a get web service using Alamofire4.0 and swift 3.0, but it always show me invalid json error, but when I test the same api in postamn is shows perfect response also I have validated json and all online forms validated that.
I found that calling
Alamofire.request(apiURLStr, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).responseString { (responseObject) in
var jsonString = responseObject.result.value
jsonString = jsonString?.replacingOccurrences(of: "\n", with: "")
}
I have to replace "\n" manually but I want this inbuilt and serialise json data as in postman.
this is my json that am getting from Alamofire :
\n{\n \"id\": 22,\n \"category\": 4,\n \"heading\": \"Sebastian Vettel wins tense Bahrain Grand Prix, Lewis Hamilton second\",\n \"subHeading\" : \"Sebastian Vettel claimed the outright lead of the Formula One championship by winning a tense Bahrain Grand Prix, despite a late charge from Lewis Hamilton.\",\n \"text\" : \"SAKHIR, Bahrain -- Sebastian Vettel claimed the outright lead of the Formula One championship by winning a tense Bahrain Grand Prix, despite a late charge from Lewis Hamilton.\",\n \"picture\" : \"http://www.sebastianvettel.de/images/Galerie-Modul/2017/2017-04-30-GP-Russland.jpg\",\n \"company\" : \"Ferrari\",\n \"author\" : \"Neil\",\n \"published\" : \"2017-04-19 20:20:22\", \n \"updated\" : \"2017-04-19 20:20:22\",\n \"visible\" : \"Y\" \n}
Thanks in advance