0
Hello, I have a question. I need to pass a CPF entered by the user as a parameter in my POST call to return with his data. The call works with a CPF already registered, but only works if the CPF is passed directly as parameter, as I did below and type NSDictionary
. How to pass the CPF entered by the user as a parameter in the call? Follow 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 take the data of this CPF, but I want that in place of this predefined CPF is the one typed by the user (cpfPesquisa
), how can I do that? Thanks for your help.
recalling that the
NSDictionary
may be omitted from the declaration:let parameters = ["cpf":cpfPesquisa]
– iTSangar
@iTSangar Thanks for the reminder.
– Victor Stafusa