How to send parameter and body both using Alamofire separately?

Viewed 812

I want to use Alamofire to send parameter and body both. I have seen tutorials and read QA where people use parameters to use as body too as in this one:

let parameters: Parameters = [
            "fullName": fullName,
            "mobileNumber": mobileNumber,
            "password": password
        ]
Alamofire.request(requestAddress , method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: header).responseJSON { response in
// utility
}

I am not sure how I should send body not using parameters as I need to send both parameters and body both.

1 Answers

You can either pass your request body with Parameters or as Data with a URLRequest object. My guess is that you can't make it happen both. If you also like to pass over some information as queryString parameters you can do it by setting them in a URLRequest like in this answer.

urlRequest.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")
Related