I want to print my request.httpBody sent.
In backend they say that they have not received , so I want to print and see in my console what is being sent.
when I print(request.httpBody) I get bytes
my code
let param = "AppId=\(Config.AppID)&uuid=\(Config.uuid)&file=\("file")&id=\(ID)"
var requestBodyData = (dataString as NSString).data(using: String.Encoding.utf8.rawValue)
requestBodyData?.append(param.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))!)
do {
request.httpBody = requestBodyData
} catch let error {
print(error.localizedDescription)
}
//How to print this request.httpBody ?
// Make an asynchronous call so as not to hold up other processes.
URLSession.shared.dataTask(with: request) { data, response, error in
// get main queue to communicate back to user
DispatchQueue.main.async(execute: {
if error == nil {
do {
// json containes $returnArray from php
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
}
)}