0

I have checked many stack overflow questions but unable to find answer for the following problem. How can I request a post api which has parameters like get api using Alamofire Swift?

Request:

http://dev.practice.com/api/v1/test/apply?id=51&social_id=2

Body:

"url": https://www.social.com/some_image_url

I have tried with the following way but it's not working:

let urlString = "http://dev.practice.com/api/v1/test/apply?id=51&social_id=2"

Alamofire.request(urlString, method: .post, parameters: ["url": "https://www.social.com/some_image_url"],encoding: JSONEncoding.httpBody, headers: header).responseJSON {  
response in
  switch response.result {
                case .success:
                    print(response)

                    break
                case .failure(let error):

                    print(error)
                }
}
  • To be clear, are you asking about URL encoded parameters in the URL and a JSON body in the same request? – Jon Shier Oct 20 '19 at 05:06

1 Answers1

0

The answer is:

We have to request the get api like parameters as queryString and post body parameters as httpBody with the request.