Я мое быстрое приложение. Я хочу создать запрос POST с помощью alamofire
Запрос
$ curl \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-X POST -d '{ "user": { "email": "[email protected]", "password": "1234" } }' \
http://localhost:3000/users/sign_in
Мой код
let URL = NSURL(string: "https://lobo-api.herokuapp.com/users/sign_up")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.HTTPMethod = "GET"
let parameters = ["user": ["email": "[email protected]", "password": "OPOPO"]]
var JSONSerializationError: NSError? = nil
mutableURLRequest.HTTPBody = NSJSONSerialization.dataWithJSONObject(parameters, options: nil, error: &JSONSerializationError)
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Accept")
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
Alamofire.request(mutableURLRequest).responseJSON { (request, response, data, error) in
println(error)
println(response)
println(data)
println(error)
}
у меня есть эта ошибка
Необязательно( {URL-адрес: https://lobo-api.herokuapp.com/users/sign_up } { код состояния: 404, заголовки {
Connection = "keep-alive";
"Content-Length" = 1564;
"Content-Type" = "text/html; charset=utf- 8";
Date = "Sun, 05 Apr 2015 19:54:11 GMT";
Server = Cowboy;
Via = "1.1 vegur";
"X-Request-Id" = "12df8182-c91e-439f-b773-2b2e48f3f0c6";
"X-Runtime" = "0.007897";
} })
nil
Необязательный(Error Domain=NSCocoaErrorDomain Code=3840 "Операция не удалось завершить. (Ошибка Cocoa 3840.)" (Недопустимое значение около символа 0.) UserInfo=0x170678500 {NSDebugDescription=Недопустимое значение около символа 0.})
POST
, верно? - person mattt   schedule 06.04.2015