Created
May 17, 2017 14:45
-
-
Save OctoberHammer/777a798f89b5704522260a9e23165a35 to your computer and use it in GitHub Desktop.
curl into Alamofire
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sendRequestRequest() { | |
| /** | |
| Request | |
| get https://parseapi.back4app.com/classes/category | |
| */ | |
| // Add Headers | |
| let headers = [ | |
| "X-Parse-Master-Key":"qTJ3eatgZppvAWqkb82WsCoqG9MqRog2MBXqRHHv", | |
| "X-Parse-Application-Id":"ad383bxkAmwAgKgPEqZHjewleWi2bLmNTlctBuky", | |
| "Content-Type":"text/plain; charset=utf-8", | |
| ] | |
| // Fetch Request | |
| //Alamofire.request("https://parseapi.back4app.com/classes/category?where=%7B%22parentID%22%3A%7B%22%24exists%22%3Afalse%7D%7D", method: .get, headers: headers) // SUCCESS | |
| //Alamofire.request("https://parseapi.back4app.com/classes/category?where=%7B%22parentID%22:%7B%22$exists%22:false%7D%7D", method: .get, headers: headers) // .urlQueryAllowed - SUCCESS | |
| //Alamofire.request("https:%2F%2Fparseapi.back4app.com%2Fclasses%2Fcategory%3Fwhere=%7B%22parentID%22:%7B%22$exists%22:false%7D%7D", method: .get, headers: headers) // .urlHostAllowed - FAILURE | |
| //Alamofire.request("https://parseapi.back4app.com/classes/category?where=%7B%22parentID%22:%7B%22$exists%22:false%7D%7D", method: .get, headers: headers) //.urlFragmentAllowed - SUCCESS | |
| Alamofire.request("https://parseapi.back4app.com/classes/category?where=%7B%22parentID%22:%7B%22$exists%22:false%7D%7D", method: .get, headers: headers) // .urlHostAllowed но только к той части строки, которая после знака вопроса - SUCCESS | |
| .validate(statusCode: 200..<300) | |
| .responseJSON { response in | |
| if (response.result.error == nil) { | |
| debugPrint("HTTP Response Body: \(response.data)") | |
| } | |
| else { | |
| debugPrint("HTTP Request failed: \(response.result.error)") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment