0

I am trying to use following code for sending some information to the server.

var request = URLRequest(url: URL(string: GlobalVariable.globalIpAdresDispatch)!)
request.httpMethod = "POST"
request.addValue("application/x-www-form-urlencoded; Charset=utf-8", forHTTPHeaderField: "Content-Type")
let postString = "saveBeyanname" + "&jp=" + myDraft + "&token=" + GlobalVariable.globalToken
request.httpBody = postString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlFragmentAllowed)?.data(using: .utf8)

myDraft variable comprises of a json string which includes ö,ç,i,ü letters. However when I send these information to server it is not accepting and they are converting ÅiÄüçö meaningless information. I have searched a lot and looked similar questions but still not working. How can I create my post string to send a server in a correct way?

atalayasa
  • 3,310
  • 25
  • 42

0 Answers0