I’m doing a Demo App in Swift 2
that makes an HTTP
POST
request. But don’t understand why my request doesn't hit the server.
I’m using Alamofire 3.0
, Xcode 7.2
, swift 2.0
.
I installed the Alamofire
pod based on this link: https://github.com/Alamofire/Alamofire#requirements
And my string is
str = "{videos{title,videourl,imageurl}}"
Here my code is:
Alamofire.request(
.POST,
url,
parameters: Dictionary(),
encoding: .Custom({
(convertible, params) in
let mutableRequest = convertible.URLRequest.copy() as! NSMutableURLRequest
mutableRequest.setValue("application/graphql", forHTTPHeaderField: "Content-Type")
mutableRequest.HTTPBody = str.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
return (mutableRequest, nil)
}),
headers: nil
).responseJSON{
(JSON) -> Void in
if JSON.result.value != nil
{
print(JSON.result.value)
self.delegate.successReponse(JSON.result.value!, withType: type)
}
else
{
}
}
When i’m printing the JSON.result.value
, it’s showing like this:
Optional({
errors = (
{
}
);
})
I don’t understand why it is not reaching to the server.