title: How do I serialize data into a JSON object
body: <p>I try to POST a JSON into my web server but it doesn't work at all. It works for "DELETE" and "GET" , but for "POST" it's not working at all and Get the error.</p>
  
  <p>it's my code:</p>
  
  <pre><code> let postsEndpoint:String = "http://ideabase.herokuapp.com/categories"
      guard let postsURL = NSURL(string: postsEndpoint) else {
          print("Error: cannot create URL")
          return
      }
      let postsUrlRequest = NSMutableURLRequest(URL: postsURL)
      postsUrlRequest.HTTPMethod = "POST"
  
      let newPost: NSDictionary = ["id":7, "title": "Purple","created_at": "2015-12-08 08:06:55","updated_at":"2015-12-08 08:06:55"]
      do {
          let jsonPost = try NSJSONSerialization.dataWithJSONObject(newPost, options: [])
          postsUrlRequest.HTTPBody = jsonPost
  
          let config = NSURLSessionConfiguration.defaultSessionConfiguration()
          let session = NSURLSession(configuration: config)
  
          let createTask = session.dataTaskWithRequest(postsUrlRequest, completionHandler: {
              (data, response, error) in
              guard let responseData = data else {
                  print("Error: did not receive data")
                  return
              }
              guard error == nil else {
                  print("error calling GET on /categories/1")
                  print(error)
                  return
              }
              // parse the result as JSON, since that's what the API provides
              let post: NSDictionary
              do {
                  post = try NSJSONSerialization.JSONObjectWithData(responseData,
                      options: []) as! NSDictionary
              } catch  {
                  print("error parsing response from POST on /categories")
                  return
              }
              // now we have the post, let's just print it to prove we can access it
              print("The post is: " + post.description)
  
              // the post object is a dictionary
              // so we just access the title using the "title" key
              // so check for a title and print it if we have one
              if let postID = post["id"] as? Int
              {
                  print("The ID is: \(postID)")
              }
          })
          createTask.resume()
  </code></pre>
  
  <p>I get the error "parsing response from POST on /categories"</p>
  
  <p>could you please help me ?</p>