Skip to content

Instantly share code, notes, and snippets.

@h2non
Last active September 11, 2022 01:38
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save h2non/6b2ae4f532349b552cb6 to your computer and use it in GitHub Desktop.
Save h2non/6b2ae4f532349b552cb6 to your computer and use it in GitHub Desktop.
JSON POST example with Alamofire
let parameters = [
"username": "foo",
"password": "123456"
]
Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON)
// -> HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}
@emrepun
Copy link

emrepun commented Jan 14, 2018

encoding: JSONEncoding.default, for swift 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment