Hello, I have a question. I need to pass a user-entered CPF as a parameter in my POST call to return with his data. The call works with an already registered CPF, but only works if the CPF is passed directly as a parameter, as I did below and type NSDictionary
. How to pass the user-entered CPF as a parameter in the call? Here's the part of my code where I call:
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.HTTPMethod = "POST"
let cpfPesquisa = cpf
let parameters: NSDictionary = ["cpf":"098.748.876-32"]
do {
mutableURLRequest.HTTPBody = try NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions())
mutableURLRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
mutableURLRequest.addValue("application/json", forHTTPHeaderField: "Accept")
The constant parameters
is passed to get the data from this CPF, but I want it to be the user-entered ( cpfPesquisa
), instead of this default CPF, how can I do this? Thanks for your help.