Alamofire post request with json encoding

alamofire post request swift 5
alamofire download file
alamofire 5 request
alamofire post request swift 4
alamofire get request swift 4
alamofire post json body swift 4
alamofire queue requests
alamofire 5 example

How to send a post request with Alamofire with parameters as json having list of integers i.e, my server expects a dictionary whose value for the key is a list of integers.

I want the parameters as {"abc":[1,2,3]}. How to send this along post request of Alamofire in swift?

Have you tried the following?

 var parameter  = ["abc": [1,2,3]]
 Alamofire.request(.POST, "http://www.yoursite.com/api" , parameters:parameter)

I would also look at the documentation over at Alamofire github documentation which is really helpful.

Alamofire/Usage.md at master · Alamofire/Alamofire · GitHub, JSONParameterEncoder. POST Request with JSON-Encoded Parameters; Configuring a Custom JSONEncoder; Manual Parameter Encoding of a URLRequest. JSON POST example with Alamofire. GitHub Gist: instantly share code, notes, and snippets.

an other solution from official documentation.

let parameters = [
    "foo": "bar",
    "baz": ["a", 1],
    "qux": [
        "x": 1,
        "y": 2,
        "z": 3
    ]
]

Alamofire.request(.POST, "http://httpbin.org/post", parameters: parameters)
// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3

I dont understand how to check your data at the backend on your server but I guess you can check your abc data result like a string [1,2,3]

let parameters = [
    "abc": "[1,2,3]"
    ]
]

JSON POST example with Alamofire · GitHub, Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON). // -> HTTP body: {"foo": [1, 2, 3], "bar": {"baz":  POST request using Alamofire.request let encoding = ParameterEncoding. JSON request. use of URLRequestConvertible for Parameter passing for POST request. Let

let parameters = [
    "foo": "bar",
    "baz": ["a", 1],
    "qux": [
        "x": 1,
        "y": 2,
        "z": 3
    ]
]

    Alamofire.request(url,method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: [:]).responseJSON{
                (response) in
                print(response, parameters)
            }

This should work

ExampleCore on CocoaPods.org, Alamofire is an HTTP networking library written in Swift. Intro - Making a Request, Response Handling, Response Validation, Response Alamofire supports three types of parameter encoding including: URL , JSON and PropertyList . Hey everyone, I'm using Laravel 5.2 to develop my API and Alamofire to make my HTTP requests in my iOS app. When I try to make a GET, PUT, DELETE request I receive a proper response. But when I try to make a POST request it arrives in my

can you give us Swift4 Alamofire Post method example?, Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default) .responseJSON { response in. print(“RESPONSE :: \(​response)”). POST Request with JSON-Encoded Parameters. If no encoding is specified, Alamofire will use the text encoding specified in the HTTPURLResponse from the server.

Alamofire:Elegant HTTP Networking in Swift, Alamofire is an HTTP networking library written in Swift. Features. [x] Chainable Request / Response methods; [x] URL / JSON / plist Parameter Encoding  Contribute to Alamofire/Alamofire development by creating an account on GitHub. `Parameters` to encode onto the request. /// /// Encodes any JSON compatible

Send POST request with JSON object and query param to REST , I'm trying to send POST request to REST webservice using alamofire I'm passing json httpBody = data request = try JSONEncoding.default.encode(request)  In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the Alamofire Software Foundation to bring additional functionality to the Alamofire ecosystem. The Swift Package Manager is a tool for automating the distribution

Comments
  • Possible duplicate of Alamofire: Sending JSON as request parameter
  • Look here: github.com/Alamofire/Alamofire#json-encoding
  • yes I did. Just to debug i am sending back the request.data as a response from the server which gives me like { "abc[]" = 3;}
  • So do you want to return the same parameter as dictionary from the server? If that is the case, this sounds like a server side issue.
  • In my server it checks for a keyword named "abc" in request.data. It doesn't get this keyword.
  • request.data should be like {"abc": [1,2,3]}
  • Their documentation is horrible. Where can I use the advertised ParameterEncoding
  • Your answer does not use json encoding