I am trying to use the Yoda API and send a request using the Alamofire Fast structure. I know that the API works correctly since I tested the endpoint using the Mashape API key several times. I also see that requests are being sent (Mashape homepage on my request). However, my JSON response is always nil .
func handleRequest(words:String){ var saying = words.stringByReplacingOccurrencesOfString(" ", withString: "+"); saying = "?sentence=" + saying; let url = NSURL(string: (baseURL+saying)); println(url); var response:String; Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders = additionalHeaders; Alamofire.request(.GET, url!).responseJSON { (_, _, JSON, _) in println(JSON); } }
The words string could be βThis is my first sentenceβ and it will automatically replace the spaces β+β according to the API specification. Please ignore multiple println statements, they are for debugging only.
This is just a proof of conceptual code; it is intentionally not made by many errors, and not very for this reason. If you have any suggestions, I would appreciate it.
source share