I am new to Alamofire and Swift, so please bear with me. I am trying to upload a Product JSON to server using Alamofire. However I keep getting a status code : 400 failure. Is there any way to log the request being sent to the server so that I can check if my data format is proper. I have provided the code for upload below.
static func uploadProduct(productJSON: [String : AnyObject]) {
Alamofire.request(.POST, ServerConfig.ADD_PRODUCT_URL, parameters: productJSON, encoding: .JSON, headers: nil)
.responseJSON(completionHandler: { responseRequest, responseResponse, responseResult in
print(responseRequest!.URL)
print(responseResponse)
print(responseResult)
})
}
This is the error that I get.
sellers.strawmine.com/api/v1/products/add } { status code: 400, headers {
Connection = "keep-alive";
Date = "Tue, 06 Oct 2015 10:53:44 GMT";
Server = "nginx/1.4.6 (Ubuntu)";
"Transfer-Encoding" = Identity;
} })
FAILURE
Please help. I have spent a good amount of time on this. Thanks in advance!