title: Alamofire 4, Swift 3 and building a json body
body: <pre><code>{"title":"exampleTitle","hashTags":[{"name":"tag1"},{"name":"tag2"}],"uploadFiles":
  [{"fileBytes":"seriesOfBytes\n","filename":"upload.txt"}]}
  </code></pre>
  
  <p>That is my desired body I want to send to the backend. </p>
  
  <p>I'm using Swift 3.0 and Alamofire 4 and i have multiple questions.</p>
  
  <p><strong>first</strong>, How do i correctly create a body which contains values and arrays of values?</p>
  
  <p>My approach is:</p>
  
  <pre><code>let para:NSMutableDictionary = NSMutableDictionary()
  para.setValue("exampleTitle", forKey: "title")
  let jsonData = try! JSONSerialization.data(withJSONObject: para, options: .init(rawValue: 0))
  let jsonString = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue) as! String
  print(jsonString)
  </code></pre>
  
  <p>which gives me</p>
  
  <pre><code>{"title":"exampleTitle"}
  </code></pre>
  
  <p><strong>second</strong>, my alamofire .post request looks like the following and is not working:</p>
  
  <pre><code>Alamofire.request(postURL, method: .post, parameters: jsonString, encoding: JSONEncoding.default)
          .responseJSON { response in
              debugPrint(response)
      }
  </code></pre>
  
  <p>i get the error message: extra argument 'method' in call. If i instead of jsonString use a string of the type </p>
  
  <pre><code> var jsonString: [String : Any]
  </code></pre>
  
  <p>it does work, but i do not know how to put the body into this type.</p>
  
  <p><strong>summary</strong>
  looking for help (example would be the best) on how to create the body, and how to send it via Alamofire 4 and swift 3 to my backend. </p>