Swift-4 : How to fetch data using POST request with Parameters in URLSession with “Content-Type” :...












0















Friends, I've gone through lot's of examples, which are available on S.O. Though I haven't received proper answer, and still I'm facing issue in getting data via api request using URLSession with Post request & passing parameters with it.



First, I'ld like to show you, what I have. tried till now...



func requestApiCall(){

let renewal_id = ""
let policy_no = ""
let client_name = ""
let client_id = ""
let product_name = ""
let created_date_from = ""
let created_date_to = ""
let policy_expiry_from = ""
let policy_expiry_to = ""

self.parameters = ["renewal_id":renewal_id,"policy_no":policy_no,"client_name":client_name,"client_id":client_id,"product_name":product_name,"created_date_from":created_date_from,"created_date_to":created_date_to,"policy_expiry_from":policy_expiry_from,"policy_expiry_to":policy_expiry_to]

let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"Accept" : "application/json",
"Content-Type" : "application/x-www-form-urlencoded"
]
let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url");
let serviceUrl = URL(string: Url)
var request = URLRequest(url: serviceUrl!)
print(request.url!)
request.httpMethod = "POST"
request.timeoutInterval = 60

request.httpBody = try! JSONSerialization.data(withJSONObject: parameters!, options: )

let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in

if error == nil{
print(response!)
}
else {
print(error?.localizedDescription as Any)
}

print(response!)
guard let httpResponse = response as? HTTPURLResponse, let receivedData = data
else {
print("error: not a valid http response")
return
}

switch (httpResponse.statusCode)
{
case 200: //The request was fulfilled
let response = NSString (data: receivedData, encoding: String.Encoding.utf8.rawValue)

if response == "SUCCESS"
{
print("Network - HandShaking Successfull...!!!")
}
else{
print("Network - HandShaking is not successfull...!!!")
}

case 400:
print("response-status - 400 : The request had bad syntax or was inherently impossible to be satisfied.")
case 500:
print("nresponse-status - 500 : Internal Server Error...!!!")
default:
print("response-status - Unknown : Received Response => (httpResponse.statusCode)")
}
})
task.resume()
}


After running above function, I'm getting httpResponse.statusCode = 500



But when I run this in postman, I get response properly, as aspected.



Postman Api-Request



Also I have tried to generate code-snippets through postman...which are as follow...



func postmanSnippetApiCall(){
let headers = [
"Content-Type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"Postman-Token": "5d571157-86c5-4eac-ba6d-b00779ae5dbd"
]

let postData = NSMutableData(data: "renewal_id=".data(using: String.Encoding.utf8)!)
postData.append("&policy_no=".data(using: String.Encoding.utf8)!)
postData.append("&client_name=".data(using: String.Encoding.utf8)!)
postData.append("&client_id=".data(using: String.Encoding.utf8)!)
postData.append("&product_name=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_from=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_to=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_from=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_to=".data(using: String.Encoding.utf8)!)
postData.append("&undefined=undefined".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "http://myapiurl")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})

dataTask.resume()
}


But in postman generated code snippet, I'm receiving error on this line i.e request.httpBody = postData as Data and error is this one : Cannot convert value of type 'NSMutableData' to type 'Data' in coercion



If I use thirdParty Library i.e Alamofire, then I'm able to get data very easily.



Alamofire code snippet...runs perfectly..& gives proper response.



func apiRequestByAlamofire(){
let urlString = "http://myapiurl"

let params: [String: Any]? = ["renewal_id":"","policy_no":"","client_name":"","client_id":"","product_name":"","created_date_from":"","created_date_to":"","policy_expiry_from":"","policy_expiry_to":""]

Alamofire.request(urlString, method: .post, parameters: params).responseJSON { response in
print(response) //Here getting perfect response successfully...!!!
}

}


But still I'm struggling this via URLSession...!!!



And still I doubt, that why I'm getting too much problems, while doing with URLSession.



Friends for above my doubt, please I'm open to your suggestions, as well as please help me out to understand it.



Don't know, where am I going wrong. please help me out here.










share|improve this question




















  • 1





    There is an option of generating Code snippets in postman, try that out.

    – Shahzaib Qureshi
    Nov 20 '18 at 7:51











  • Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

    – ASHISH
    Nov 20 '18 at 7:55











  • If you try the Objective-C Code generated by Postman it doesn't work?

    – Larme
    Nov 20 '18 at 8:57











  • Hi @Larme can you help me out in this.

    – ASHISH
    Nov 20 '18 at 9:09











  • @Larme yes it does work

    – Shahzaib Qureshi
    Nov 20 '18 at 9:18
















0















Friends, I've gone through lot's of examples, which are available on S.O. Though I haven't received proper answer, and still I'm facing issue in getting data via api request using URLSession with Post request & passing parameters with it.



First, I'ld like to show you, what I have. tried till now...



func requestApiCall(){

let renewal_id = ""
let policy_no = ""
let client_name = ""
let client_id = ""
let product_name = ""
let created_date_from = ""
let created_date_to = ""
let policy_expiry_from = ""
let policy_expiry_to = ""

self.parameters = ["renewal_id":renewal_id,"policy_no":policy_no,"client_name":client_name,"client_id":client_id,"product_name":product_name,"created_date_from":created_date_from,"created_date_to":created_date_to,"policy_expiry_from":policy_expiry_from,"policy_expiry_to":policy_expiry_to]

let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"Accept" : "application/json",
"Content-Type" : "application/x-www-form-urlencoded"
]
let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url");
let serviceUrl = URL(string: Url)
var request = URLRequest(url: serviceUrl!)
print(request.url!)
request.httpMethod = "POST"
request.timeoutInterval = 60

request.httpBody = try! JSONSerialization.data(withJSONObject: parameters!, options: )

let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in

if error == nil{
print(response!)
}
else {
print(error?.localizedDescription as Any)
}

print(response!)
guard let httpResponse = response as? HTTPURLResponse, let receivedData = data
else {
print("error: not a valid http response")
return
}

switch (httpResponse.statusCode)
{
case 200: //The request was fulfilled
let response = NSString (data: receivedData, encoding: String.Encoding.utf8.rawValue)

if response == "SUCCESS"
{
print("Network - HandShaking Successfull...!!!")
}
else{
print("Network - HandShaking is not successfull...!!!")
}

case 400:
print("response-status - 400 : The request had bad syntax or was inherently impossible to be satisfied.")
case 500:
print("nresponse-status - 500 : Internal Server Error...!!!")
default:
print("response-status - Unknown : Received Response => (httpResponse.statusCode)")
}
})
task.resume()
}


After running above function, I'm getting httpResponse.statusCode = 500



But when I run this in postman, I get response properly, as aspected.



Postman Api-Request



Also I have tried to generate code-snippets through postman...which are as follow...



func postmanSnippetApiCall(){
let headers = [
"Content-Type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"Postman-Token": "5d571157-86c5-4eac-ba6d-b00779ae5dbd"
]

let postData = NSMutableData(data: "renewal_id=".data(using: String.Encoding.utf8)!)
postData.append("&policy_no=".data(using: String.Encoding.utf8)!)
postData.append("&client_name=".data(using: String.Encoding.utf8)!)
postData.append("&client_id=".data(using: String.Encoding.utf8)!)
postData.append("&product_name=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_from=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_to=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_from=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_to=".data(using: String.Encoding.utf8)!)
postData.append("&undefined=undefined".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "http://myapiurl")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})

dataTask.resume()
}


But in postman generated code snippet, I'm receiving error on this line i.e request.httpBody = postData as Data and error is this one : Cannot convert value of type 'NSMutableData' to type 'Data' in coercion



If I use thirdParty Library i.e Alamofire, then I'm able to get data very easily.



Alamofire code snippet...runs perfectly..& gives proper response.



func apiRequestByAlamofire(){
let urlString = "http://myapiurl"

let params: [String: Any]? = ["renewal_id":"","policy_no":"","client_name":"","client_id":"","product_name":"","created_date_from":"","created_date_to":"","policy_expiry_from":"","policy_expiry_to":""]

Alamofire.request(urlString, method: .post, parameters: params).responseJSON { response in
print(response) //Here getting perfect response successfully...!!!
}

}


But still I'm struggling this via URLSession...!!!



And still I doubt, that why I'm getting too much problems, while doing with URLSession.



Friends for above my doubt, please I'm open to your suggestions, as well as please help me out to understand it.



Don't know, where am I going wrong. please help me out here.










share|improve this question




















  • 1





    There is an option of generating Code snippets in postman, try that out.

    – Shahzaib Qureshi
    Nov 20 '18 at 7:51











  • Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

    – ASHISH
    Nov 20 '18 at 7:55











  • If you try the Objective-C Code generated by Postman it doesn't work?

    – Larme
    Nov 20 '18 at 8:57











  • Hi @Larme can you help me out in this.

    – ASHISH
    Nov 20 '18 at 9:09











  • @Larme yes it does work

    – Shahzaib Qureshi
    Nov 20 '18 at 9:18














0












0








0








Friends, I've gone through lot's of examples, which are available on S.O. Though I haven't received proper answer, and still I'm facing issue in getting data via api request using URLSession with Post request & passing parameters with it.



First, I'ld like to show you, what I have. tried till now...



func requestApiCall(){

let renewal_id = ""
let policy_no = ""
let client_name = ""
let client_id = ""
let product_name = ""
let created_date_from = ""
let created_date_to = ""
let policy_expiry_from = ""
let policy_expiry_to = ""

self.parameters = ["renewal_id":renewal_id,"policy_no":policy_no,"client_name":client_name,"client_id":client_id,"product_name":product_name,"created_date_from":created_date_from,"created_date_to":created_date_to,"policy_expiry_from":policy_expiry_from,"policy_expiry_to":policy_expiry_to]

let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"Accept" : "application/json",
"Content-Type" : "application/x-www-form-urlencoded"
]
let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url");
let serviceUrl = URL(string: Url)
var request = URLRequest(url: serviceUrl!)
print(request.url!)
request.httpMethod = "POST"
request.timeoutInterval = 60

request.httpBody = try! JSONSerialization.data(withJSONObject: parameters!, options: )

let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in

if error == nil{
print(response!)
}
else {
print(error?.localizedDescription as Any)
}

print(response!)
guard let httpResponse = response as? HTTPURLResponse, let receivedData = data
else {
print("error: not a valid http response")
return
}

switch (httpResponse.statusCode)
{
case 200: //The request was fulfilled
let response = NSString (data: receivedData, encoding: String.Encoding.utf8.rawValue)

if response == "SUCCESS"
{
print("Network - HandShaking Successfull...!!!")
}
else{
print("Network - HandShaking is not successfull...!!!")
}

case 400:
print("response-status - 400 : The request had bad syntax or was inherently impossible to be satisfied.")
case 500:
print("nresponse-status - 500 : Internal Server Error...!!!")
default:
print("response-status - Unknown : Received Response => (httpResponse.statusCode)")
}
})
task.resume()
}


After running above function, I'm getting httpResponse.statusCode = 500



But when I run this in postman, I get response properly, as aspected.



Postman Api-Request



Also I have tried to generate code-snippets through postman...which are as follow...



func postmanSnippetApiCall(){
let headers = [
"Content-Type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"Postman-Token": "5d571157-86c5-4eac-ba6d-b00779ae5dbd"
]

let postData = NSMutableData(data: "renewal_id=".data(using: String.Encoding.utf8)!)
postData.append("&policy_no=".data(using: String.Encoding.utf8)!)
postData.append("&client_name=".data(using: String.Encoding.utf8)!)
postData.append("&client_id=".data(using: String.Encoding.utf8)!)
postData.append("&product_name=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_from=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_to=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_from=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_to=".data(using: String.Encoding.utf8)!)
postData.append("&undefined=undefined".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "http://myapiurl")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})

dataTask.resume()
}


But in postman generated code snippet, I'm receiving error on this line i.e request.httpBody = postData as Data and error is this one : Cannot convert value of type 'NSMutableData' to type 'Data' in coercion



If I use thirdParty Library i.e Alamofire, then I'm able to get data very easily.



Alamofire code snippet...runs perfectly..& gives proper response.



func apiRequestByAlamofire(){
let urlString = "http://myapiurl"

let params: [String: Any]? = ["renewal_id":"","policy_no":"","client_name":"","client_id":"","product_name":"","created_date_from":"","created_date_to":"","policy_expiry_from":"","policy_expiry_to":""]

Alamofire.request(urlString, method: .post, parameters: params).responseJSON { response in
print(response) //Here getting perfect response successfully...!!!
}

}


But still I'm struggling this via URLSession...!!!



And still I doubt, that why I'm getting too much problems, while doing with URLSession.



Friends for above my doubt, please I'm open to your suggestions, as well as please help me out to understand it.



Don't know, where am I going wrong. please help me out here.










share|improve this question
















Friends, I've gone through lot's of examples, which are available on S.O. Though I haven't received proper answer, and still I'm facing issue in getting data via api request using URLSession with Post request & passing parameters with it.



First, I'ld like to show you, what I have. tried till now...



func requestApiCall(){

let renewal_id = ""
let policy_no = ""
let client_name = ""
let client_id = ""
let product_name = ""
let created_date_from = ""
let created_date_to = ""
let policy_expiry_from = ""
let policy_expiry_to = ""

self.parameters = ["renewal_id":renewal_id,"policy_no":policy_no,"client_name":client_name,"client_id":client_id,"product_name":product_name,"created_date_from":created_date_from,"created_date_to":created_date_to,"policy_expiry_from":policy_expiry_from,"policy_expiry_to":policy_expiry_to]

let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"Accept" : "application/json",
"Content-Type" : "application/x-www-form-urlencoded"
]
let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url");
let serviceUrl = URL(string: Url)
var request = URLRequest(url: serviceUrl!)
print(request.url!)
request.httpMethod = "POST"
request.timeoutInterval = 60

request.httpBody = try! JSONSerialization.data(withJSONObject: parameters!, options: )

let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in

if error == nil{
print(response!)
}
else {
print(error?.localizedDescription as Any)
}

print(response!)
guard let httpResponse = response as? HTTPURLResponse, let receivedData = data
else {
print("error: not a valid http response")
return
}

switch (httpResponse.statusCode)
{
case 200: //The request was fulfilled
let response = NSString (data: receivedData, encoding: String.Encoding.utf8.rawValue)

if response == "SUCCESS"
{
print("Network - HandShaking Successfull...!!!")
}
else{
print("Network - HandShaking is not successfull...!!!")
}

case 400:
print("response-status - 400 : The request had bad syntax or was inherently impossible to be satisfied.")
case 500:
print("nresponse-status - 500 : Internal Server Error...!!!")
default:
print("response-status - Unknown : Received Response => (httpResponse.statusCode)")
}
})
task.resume()
}


After running above function, I'm getting httpResponse.statusCode = 500



But when I run this in postman, I get response properly, as aspected.



Postman Api-Request



Also I have tried to generate code-snippets through postman...which are as follow...



func postmanSnippetApiCall(){
let headers = [
"Content-Type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"Postman-Token": "5d571157-86c5-4eac-ba6d-b00779ae5dbd"
]

let postData = NSMutableData(data: "renewal_id=".data(using: String.Encoding.utf8)!)
postData.append("&policy_no=".data(using: String.Encoding.utf8)!)
postData.append("&client_name=".data(using: String.Encoding.utf8)!)
postData.append("&client_id=".data(using: String.Encoding.utf8)!)
postData.append("&product_name=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_from=".data(using: String.Encoding.utf8)!)
postData.append("&created_date_to=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_from=".data(using: String.Encoding.utf8)!)
postData.append("&policy_expiry_to=".data(using: String.Encoding.utf8)!)
postData.append("&undefined=undefined".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "http://myapiurl")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})

dataTask.resume()
}


But in postman generated code snippet, I'm receiving error on this line i.e request.httpBody = postData as Data and error is this one : Cannot convert value of type 'NSMutableData' to type 'Data' in coercion



If I use thirdParty Library i.e Alamofire, then I'm able to get data very easily.



Alamofire code snippet...runs perfectly..& gives proper response.



func apiRequestByAlamofire(){
let urlString = "http://myapiurl"

let params: [String: Any]? = ["renewal_id":"","policy_no":"","client_name":"","client_id":"","product_name":"","created_date_from":"","created_date_to":"","policy_expiry_from":"","policy_expiry_to":""]

Alamofire.request(urlString, method: .post, parameters: params).responseJSON { response in
print(response) //Here getting perfect response successfully...!!!
}

}


But still I'm struggling this via URLSession...!!!



And still I doubt, that why I'm getting too much problems, while doing with URLSession.



Friends for above my doubt, please I'm open to your suggestions, as well as please help me out to understand it.



Don't know, where am I going wrong. please help me out here.







ios swift swift4 nsurlsession swift4.2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 11:23







ASHISH

















asked Nov 20 '18 at 7:48









ASHISHASHISH

65




65








  • 1





    There is an option of generating Code snippets in postman, try that out.

    – Shahzaib Qureshi
    Nov 20 '18 at 7:51











  • Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

    – ASHISH
    Nov 20 '18 at 7:55











  • If you try the Objective-C Code generated by Postman it doesn't work?

    – Larme
    Nov 20 '18 at 8:57











  • Hi @Larme can you help me out in this.

    – ASHISH
    Nov 20 '18 at 9:09











  • @Larme yes it does work

    – Shahzaib Qureshi
    Nov 20 '18 at 9:18














  • 1





    There is an option of generating Code snippets in postman, try that out.

    – Shahzaib Qureshi
    Nov 20 '18 at 7:51











  • Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

    – ASHISH
    Nov 20 '18 at 7:55











  • If you try the Objective-C Code generated by Postman it doesn't work?

    – Larme
    Nov 20 '18 at 8:57











  • Hi @Larme can you help me out in this.

    – ASHISH
    Nov 20 '18 at 9:09











  • @Larme yes it does work

    – Shahzaib Qureshi
    Nov 20 '18 at 9:18








1




1





There is an option of generating Code snippets in postman, try that out.

– Shahzaib Qureshi
Nov 20 '18 at 7:51





There is an option of generating Code snippets in postman, try that out.

– Shahzaib Qureshi
Nov 20 '18 at 7:51













Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

– ASHISH
Nov 20 '18 at 7:55





Yes, I've tried that too...but not able to resolve it. Getting response status as 500.

– ASHISH
Nov 20 '18 at 7:55













If you try the Objective-C Code generated by Postman it doesn't work?

– Larme
Nov 20 '18 at 8:57





If you try the Objective-C Code generated by Postman it doesn't work?

– Larme
Nov 20 '18 at 8:57













Hi @Larme can you help me out in this.

– ASHISH
Nov 20 '18 at 9:09





Hi @Larme can you help me out in this.

– ASHISH
Nov 20 '18 at 9:09













@Larme yes it does work

– Shahzaib Qureshi
Nov 20 '18 at 9:18





@Larme yes it does work

– Shahzaib Qureshi
Nov 20 '18 at 9:18












2 Answers
2






active

oldest

votes


















0














I am giving you simple function, You can edit this function as per your requirement. You can change your URL and params as well. And in the response, I have written two-line if you are taking JSON array from the server then use the first one if you are taking object then second one else remove Both lines.



func abc()  {
let request = NSMutableURLRequest(url: URL(string: "Your URL")!)
request.httpMethod = "POST"
let postString = "param_name_one=( value_1 )&param_name_two=(value_2)&........."
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if(error != nil){
// Show Error Message
} else{
do {
//For JSON ARRAY
let jsonItem = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! NSArray
let json = jsonItem[0] as AnyObject
//For JSON object
let json_object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as AnyObject
print(json_object)

} catch {

}
}
}
task.resume();
}



Hopefully this function will help you!







share|improve this answer
























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

    – ASHISH
    Nov 20 '18 at 10:32











  • This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

    – Pushpendra
    Nov 20 '18 at 10:49











  • But in Alamofire, I'm getting data properly. So what is the issue with URLSession

    – ASHISH
    Nov 20 '18 at 11:19











  • try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

    – Pushpendra
    Nov 20 '18 at 11:56



















0














Try to add the headers in URLRequest instead of URLSession directly and also try different Content-Types and Accepts like application/json, application/x-www-form-urlencoded etc..



let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = TimeInterval(30)
config.timeoutIntervalForResource = TimeInterval(30)

let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url")
let serviceUrl = URL(string: Url)

var request = URLRequest(url: serviceUrl!)
print(request.url!)

request.httpMethod = "POST"

let parameters: [String: Any]? = //Request parameters in Dictionary format like ["user_id": 2, "name": "TestUser"]

//Set body to url request
if parameters != nil {

do {
let bodyData = try JSONSerialization.data(withJSONObject: parameters!,
options: JSONSerialization.WritingOptions.prettyPrinted)
request.httpBody = bodyData
} catch let error {
print(error.localizedDescription)
}
}

request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Try different types of Content-Types here like "application/json", etc.
request.addValue("application/json", forHTTPHeaderField: "Accept") //Try different types of Content-Types here like "application/json", etc.

let task = session.dataTask(with: request) { (data, response, error) in

// Your code here
guard data != nil && error == nil else {
return
}

let apiResponse = String.init(data: data!, encoding: String.Encoding.utf8)!
print(apiResponse)
}

task.resume()
session.finishTasksAndInvalidate()


Please visit the link below for how to code with URLSession.



https://github.com/sateeshyegireddi/MovieFlix/blob/master/MovieFlix/MovieFlix/API/APIHandler.swift






share|improve this answer


























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet.

    – ASHISH
    Nov 20 '18 at 10:02











  • Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

    – Sateesh
    Nov 20 '18 at 10:09













  • Also I want to pass parameters along with request.

    – ASHISH
    Nov 20 '18 at 10:24











  • Answer has been edited please check once.

    – Sateesh
    Nov 20 '18 at 10:31











  • {"Message":"An error has occurred."} Getting this in response

    – ASHISH
    Nov 20 '18 at 10:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388406%2fswift-4-how-to-fetch-data-using-post-request-with-parameters-in-urlsession-wit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I am giving you simple function, You can edit this function as per your requirement. You can change your URL and params as well. And in the response, I have written two-line if you are taking JSON array from the server then use the first one if you are taking object then second one else remove Both lines.



func abc()  {
let request = NSMutableURLRequest(url: URL(string: "Your URL")!)
request.httpMethod = "POST"
let postString = "param_name_one=( value_1 )&param_name_two=(value_2)&........."
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if(error != nil){
// Show Error Message
} else{
do {
//For JSON ARRAY
let jsonItem = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! NSArray
let json = jsonItem[0] as AnyObject
//For JSON object
let json_object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as AnyObject
print(json_object)

} catch {

}
}
}
task.resume();
}



Hopefully this function will help you!







share|improve this answer
























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

    – ASHISH
    Nov 20 '18 at 10:32











  • This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

    – Pushpendra
    Nov 20 '18 at 10:49











  • But in Alamofire, I'm getting data properly. So what is the issue with URLSession

    – ASHISH
    Nov 20 '18 at 11:19











  • try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

    – Pushpendra
    Nov 20 '18 at 11:56
















0














I am giving you simple function, You can edit this function as per your requirement. You can change your URL and params as well. And in the response, I have written two-line if you are taking JSON array from the server then use the first one if you are taking object then second one else remove Both lines.



func abc()  {
let request = NSMutableURLRequest(url: URL(string: "Your URL")!)
request.httpMethod = "POST"
let postString = "param_name_one=( value_1 )&param_name_two=(value_2)&........."
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if(error != nil){
// Show Error Message
} else{
do {
//For JSON ARRAY
let jsonItem = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! NSArray
let json = jsonItem[0] as AnyObject
//For JSON object
let json_object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as AnyObject
print(json_object)

} catch {

}
}
}
task.resume();
}



Hopefully this function will help you!







share|improve this answer
























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

    – ASHISH
    Nov 20 '18 at 10:32











  • This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

    – Pushpendra
    Nov 20 '18 at 10:49











  • But in Alamofire, I'm getting data properly. So what is the issue with URLSession

    – ASHISH
    Nov 20 '18 at 11:19











  • try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

    – Pushpendra
    Nov 20 '18 at 11:56














0












0








0







I am giving you simple function, You can edit this function as per your requirement. You can change your URL and params as well. And in the response, I have written two-line if you are taking JSON array from the server then use the first one if you are taking object then second one else remove Both lines.



func abc()  {
let request = NSMutableURLRequest(url: URL(string: "Your URL")!)
request.httpMethod = "POST"
let postString = "param_name_one=( value_1 )&param_name_two=(value_2)&........."
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if(error != nil){
// Show Error Message
} else{
do {
//For JSON ARRAY
let jsonItem = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! NSArray
let json = jsonItem[0] as AnyObject
//For JSON object
let json_object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as AnyObject
print(json_object)

} catch {

}
}
}
task.resume();
}



Hopefully this function will help you!







share|improve this answer













I am giving you simple function, You can edit this function as per your requirement. You can change your URL and params as well. And in the response, I have written two-line if you are taking JSON array from the server then use the first one if you are taking object then second one else remove Both lines.



func abc()  {
let request = NSMutableURLRequest(url: URL(string: "Your URL")!)
request.httpMethod = "POST"
let postString = "param_name_one=( value_1 )&param_name_two=(value_2)&........."
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if(error != nil){
// Show Error Message
} else{
do {
//For JSON ARRAY
let jsonItem = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! NSArray
let json = jsonItem[0] as AnyObject
//For JSON object
let json_object = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as AnyObject
print(json_object)

} catch {

}
}
}
task.resume();
}



Hopefully this function will help you!








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 10:18









PushpendraPushpendra

877821




877821













  • No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

    – ASHISH
    Nov 20 '18 at 10:32











  • This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

    – Pushpendra
    Nov 20 '18 at 10:49











  • But in Alamofire, I'm getting data properly. So what is the issue with URLSession

    – ASHISH
    Nov 20 '18 at 11:19











  • try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

    – Pushpendra
    Nov 20 '18 at 11:56



















  • No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

    – ASHISH
    Nov 20 '18 at 10:32











  • This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

    – Pushpendra
    Nov 20 '18 at 10:49











  • But in Alamofire, I'm getting data properly. So what is the issue with URLSession

    – ASHISH
    Nov 20 '18 at 11:19











  • try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

    – Pushpendra
    Nov 20 '18 at 11:56

















No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

– ASHISH
Nov 20 '18 at 10:32





No, I haven't received data, but yes I'm getting status code 200, but no response yet. I'm sending parameter's with only keys, there is no value.

– ASHISH
Nov 20 '18 at 10:32













This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

– Pushpendra
Nov 20 '18 at 10:49





This is only the technique for fetching the data, Please try to debug your code at server side and edit your question with your response, whatever you are getting from the server. You can use PostMan for this. or take a guidance from your backend developer.

– Pushpendra
Nov 20 '18 at 10:49













But in Alamofire, I'm getting data properly. So what is the issue with URLSession

– ASHISH
Nov 20 '18 at 11:19





But in Alamofire, I'm getting data properly. So what is the issue with URLSession

– ASHISH
Nov 20 '18 at 11:19













try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

– Pushpendra
Nov 20 '18 at 11:56





try to print your response and then try to print next stage data!, Only debugging is the best solution for that, because same code is working on my system.

– Pushpendra
Nov 20 '18 at 11:56













0














Try to add the headers in URLRequest instead of URLSession directly and also try different Content-Types and Accepts like application/json, application/x-www-form-urlencoded etc..



let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = TimeInterval(30)
config.timeoutIntervalForResource = TimeInterval(30)

let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url")
let serviceUrl = URL(string: Url)

var request = URLRequest(url: serviceUrl!)
print(request.url!)

request.httpMethod = "POST"

let parameters: [String: Any]? = //Request parameters in Dictionary format like ["user_id": 2, "name": "TestUser"]

//Set body to url request
if parameters != nil {

do {
let bodyData = try JSONSerialization.data(withJSONObject: parameters!,
options: JSONSerialization.WritingOptions.prettyPrinted)
request.httpBody = bodyData
} catch let error {
print(error.localizedDescription)
}
}

request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Try different types of Content-Types here like "application/json", etc.
request.addValue("application/json", forHTTPHeaderField: "Accept") //Try different types of Content-Types here like "application/json", etc.

let task = session.dataTask(with: request) { (data, response, error) in

// Your code here
guard data != nil && error == nil else {
return
}

let apiResponse = String.init(data: data!, encoding: String.Encoding.utf8)!
print(apiResponse)
}

task.resume()
session.finishTasksAndInvalidate()


Please visit the link below for how to code with URLSession.



https://github.com/sateeshyegireddi/MovieFlix/blob/master/MovieFlix/MovieFlix/API/APIHandler.swift






share|improve this answer


























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet.

    – ASHISH
    Nov 20 '18 at 10:02











  • Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

    – Sateesh
    Nov 20 '18 at 10:09













  • Also I want to pass parameters along with request.

    – ASHISH
    Nov 20 '18 at 10:24











  • Answer has been edited please check once.

    – Sateesh
    Nov 20 '18 at 10:31











  • {"Message":"An error has occurred."} Getting this in response

    – ASHISH
    Nov 20 '18 at 10:36
















0














Try to add the headers in URLRequest instead of URLSession directly and also try different Content-Types and Accepts like application/json, application/x-www-form-urlencoded etc..



let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = TimeInterval(30)
config.timeoutIntervalForResource = TimeInterval(30)

let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url")
let serviceUrl = URL(string: Url)

var request = URLRequest(url: serviceUrl!)
print(request.url!)

request.httpMethod = "POST"

let parameters: [String: Any]? = //Request parameters in Dictionary format like ["user_id": 2, "name": "TestUser"]

//Set body to url request
if parameters != nil {

do {
let bodyData = try JSONSerialization.data(withJSONObject: parameters!,
options: JSONSerialization.WritingOptions.prettyPrinted)
request.httpBody = bodyData
} catch let error {
print(error.localizedDescription)
}
}

request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Try different types of Content-Types here like "application/json", etc.
request.addValue("application/json", forHTTPHeaderField: "Accept") //Try different types of Content-Types here like "application/json", etc.

let task = session.dataTask(with: request) { (data, response, error) in

// Your code here
guard data != nil && error == nil else {
return
}

let apiResponse = String.init(data: data!, encoding: String.Encoding.utf8)!
print(apiResponse)
}

task.resume()
session.finishTasksAndInvalidate()


Please visit the link below for how to code with URLSession.



https://github.com/sateeshyegireddi/MovieFlix/blob/master/MovieFlix/MovieFlix/API/APIHandler.swift






share|improve this answer


























  • No, I haven't received data, but yes I'm getting status code 200, but no response yet.

    – ASHISH
    Nov 20 '18 at 10:02











  • Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

    – Sateesh
    Nov 20 '18 at 10:09













  • Also I want to pass parameters along with request.

    – ASHISH
    Nov 20 '18 at 10:24











  • Answer has been edited please check once.

    – Sateesh
    Nov 20 '18 at 10:31











  • {"Message":"An error has occurred."} Getting this in response

    – ASHISH
    Nov 20 '18 at 10:36














0












0








0







Try to add the headers in URLRequest instead of URLSession directly and also try different Content-Types and Accepts like application/json, application/x-www-form-urlencoded etc..



let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = TimeInterval(30)
config.timeoutIntervalForResource = TimeInterval(30)

let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url")
let serviceUrl = URL(string: Url)

var request = URLRequest(url: serviceUrl!)
print(request.url!)

request.httpMethod = "POST"

let parameters: [String: Any]? = //Request parameters in Dictionary format like ["user_id": 2, "name": "TestUser"]

//Set body to url request
if parameters != nil {

do {
let bodyData = try JSONSerialization.data(withJSONObject: parameters!,
options: JSONSerialization.WritingOptions.prettyPrinted)
request.httpBody = bodyData
} catch let error {
print(error.localizedDescription)
}
}

request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Try different types of Content-Types here like "application/json", etc.
request.addValue("application/json", forHTTPHeaderField: "Accept") //Try different types of Content-Types here like "application/json", etc.

let task = session.dataTask(with: request) { (data, response, error) in

// Your code here
guard data != nil && error == nil else {
return
}

let apiResponse = String.init(data: data!, encoding: String.Encoding.utf8)!
print(apiResponse)
}

task.resume()
session.finishTasksAndInvalidate()


Please visit the link below for how to code with URLSession.



https://github.com/sateeshyegireddi/MovieFlix/blob/master/MovieFlix/MovieFlix/API/APIHandler.swift






share|improve this answer















Try to add the headers in URLRequest instead of URLSession directly and also try different Content-Types and Accepts like application/json, application/x-www-form-urlencoded etc..



let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = TimeInterval(30)
config.timeoutIntervalForResource = TimeInterval(30)

let session = URLSession(configuration: config)
let Url = String(format: "http://myapi-url")
let serviceUrl = URL(string: Url)

var request = URLRequest(url: serviceUrl!)
print(request.url!)

request.httpMethod = "POST"

let parameters: [String: Any]? = //Request parameters in Dictionary format like ["user_id": 2, "name": "TestUser"]

//Set body to url request
if parameters != nil {

do {
let bodyData = try JSONSerialization.data(withJSONObject: parameters!,
options: JSONSerialization.WritingOptions.prettyPrinted)
request.httpBody = bodyData
} catch let error {
print(error.localizedDescription)
}
}

request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Try different types of Content-Types here like "application/json", etc.
request.addValue("application/json", forHTTPHeaderField: "Accept") //Try different types of Content-Types here like "application/json", etc.

let task = session.dataTask(with: request) { (data, response, error) in

// Your code here
guard data != nil && error == nil else {
return
}

let apiResponse = String.init(data: data!, encoding: String.Encoding.utf8)!
print(apiResponse)
}

task.resume()
session.finishTasksAndInvalidate()


Please visit the link below for how to code with URLSession.



https://github.com/sateeshyegireddi/MovieFlix/blob/master/MovieFlix/MovieFlix/API/APIHandler.swift







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 10:30

























answered Nov 20 '18 at 9:27









SateeshSateesh

2,1171819




2,1171819













  • No, I haven't received data, but yes I'm getting status code 200, but no response yet.

    – ASHISH
    Nov 20 '18 at 10:02











  • Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

    – Sateesh
    Nov 20 '18 at 10:09













  • Also I want to pass parameters along with request.

    – ASHISH
    Nov 20 '18 at 10:24











  • Answer has been edited please check once.

    – Sateesh
    Nov 20 '18 at 10:31











  • {"Message":"An error has occurred."} Getting this in response

    – ASHISH
    Nov 20 '18 at 10:36



















  • No, I haven't received data, but yes I'm getting status code 200, but no response yet.

    – ASHISH
    Nov 20 '18 at 10:02











  • Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

    – Sateesh
    Nov 20 '18 at 10:09













  • Also I want to pass parameters along with request.

    – ASHISH
    Nov 20 '18 at 10:24











  • Answer has been edited please check once.

    – Sateesh
    Nov 20 '18 at 10:31











  • {"Message":"An error has occurred."} Getting this in response

    – ASHISH
    Nov 20 '18 at 10:36

















No, I haven't received data, but yes I'm getting status code 200, but no response yet.

– ASHISH
Nov 20 '18 at 10:02





No, I haven't received data, but yes I'm getting status code 200, but no response yet.

– ASHISH
Nov 20 '18 at 10:02













Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

– Sateesh
Nov 20 '18 at 10:09







Don't parse the HTTP response like let httpResponse = response as? HTTPURLResponse instead parse the API response which is in JSON format from data. Check the edited code in the answer below // Your code here line.

– Sateesh
Nov 20 '18 at 10:09















Also I want to pass parameters along with request.

– ASHISH
Nov 20 '18 at 10:24





Also I want to pass parameters along with request.

– ASHISH
Nov 20 '18 at 10:24













Answer has been edited please check once.

– Sateesh
Nov 20 '18 at 10:31





Answer has been edited please check once.

– Sateesh
Nov 20 '18 at 10:31













{"Message":"An error has occurred."} Getting this in response

– ASHISH
Nov 20 '18 at 10:36





{"Message":"An error has occurred."} Getting this in response

– ASHISH
Nov 20 '18 at 10:36


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388406%2fswift-4-how-to-fetch-data-using-post-request-with-parameters-in-urlsession-wit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?