title: http request delete and put
body: <p>Below is my code for HTTP request for getting and post. What I wanted to know is how to do HTTP request for delete and put. I have made it possible for get and post to work. I want to know how on the part of delete and put based on my code below. what to change in my postcode when I want to change it to delete? what is lacking? I wanted to delete using ID
  like for example "id": 16,</p>
  
  <pre><code>let parameters = ["name": "test", "desc": "test" , "reward":"1.00" , "sched":"2018-04-05T11:49:51+08:00",  "occurrence":["name": "once"]
      , "status": "created",  "created_by": "test@gmail.com","created_for": "test.com"] as [String : Any]
  
  guard let url = URL(string: "http://test.tesst.eu:8000/api/v1/test/") else { return }
  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  guard let httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: []) else { return }
  request.httpBody = httpBody
  
  let session = URLSession.shared
  session.dataTask(with: request) { (data, response, error) in
      if let response = response {
          print(response)
      }
  
      if let data = data {
          do {
              let json = try JSONSerialization.jsonObject(with: data, options: [])
              print(json)
          } catch {
              print(error)
          }
      }
  }.resume()
  </code></pre>
  
  <p>get </p>
  
  <pre><code>guard let url = URL(string: "http://test.test:8000/api/v1/test") else { return }
  
  let session = URLSession.shared
  session.dataTask(with: url) { (data, response, error) in
      if let response = response {
          print(response)
      }
  
      if let data = data {
          print(data)
          do {
              let json = try JSONSerialization.jsonObject(with: data, options: [])
              print(json)
          } catch {
              print(error)
          }
      }
  }.resume()
  </code></pre>