swiftxcodehttpmethodsalamofire

How to use custom verb with alamofire?


I want to add two custom verbs "claim" & "bind" in alamofire?

enter image description here


Solution

  • Alamofire will support fully custom HTTP methods in an upcoming update (something after 5.0.0 beta 7). Until then, building your URLRequests manually will allow you to set the method directly, as a String. Also, methods are case-sensitive, so be careful.

    request.httpMethod = "claim"

    Edit: In Alamofire's v5 release, HTTPMethod switched from an enum to a struct, so now it's as simple as creating your own value.

    extension HTTPMethod {
      static let claim = HTTPMethod(rawValue: "claim")
    }