Skip to content

Instantly share code, notes, and snippets.

@yellowred
Created September 28, 2016 04:51
Show Gist options
  • Save yellowred/0d048c206e83dcc55c16f12b1a50cdc2 to your computer and use it in GitHub Desktop.
Save yellowred/0d048c206e83dcc55c16f12b1a50cdc2 to your computer and use it in GitHub Desktop.
Save array of object in Loopback using Swift 3 + Alamofire
let financials = [
[
"amount": 777,
"date": "2016-09-24",
"rate": 1,
"text": "string",
"category": "string",
"uuid": "string",
],
[
"amount": 888,
"date": "2016-09-24",
"rate": 1,
"text": "string",
"category": "string",
"uuid": "string",
]
]
let data = try! JSONSerialization.data(withJSONObject: financials, options: [])
let jsonBatch:String = String(data: data, encoding: .utf8)!
Alamofire.request(API_URL, method: .post, parameters: [:], encoding: jsonBatch, headers: [:]).responseJSON { response in
debugPrint(response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment