Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. ["id": <null>, "error": {
  2. code = "-32700";
  3. message = "Parse error";
  4.  
  5. class ViewController: UIViewController {
  6.  
  7. override func viewDidLoad() {
  8. var userName = "root"
  9. var password = "admin01"
  10.  
  11. // http://192.168.1.1/ubus
  12. //var LOGIN_TOKEN = 0000000000000000
  13. let url: String = "http://192.168.1.1/ubus"
  14. let param: [String: Any] = ["username": "admin", "password": "admin01", "token": "0000000000000000"]
  15. Alamofire.request(url, method: .post, parameters: param,
  16. encoding: JSONEncoding.default)
  17. .responseJSON { response in
  18. guard response.result.error == nil else {
  19. // got an error in getting the data, need to handle it
  20. print("error calling post")
  21. print(response.result.error!)
  22. return
  23. }
  24.  
  25. // make sure we got some JSON since that's what we expect
  26. guard let json = response.result.value as? [String: Any] else {
  27. print("didn't get todo object as JSON from API")
  28. print("Error: (response.result.error)")
  29. return
  30. }
  31.  
  32. print(json)
  33. }
  34.  
  35.  
  36. super.viewDidLoad()
  37. // Do any additional setup after loading the view, typically from a nib.
  38. }
  39.  
  40. override func didReceiveMemoryWarning() {
  41. super.didReceiveMemoryWarning()
  42. // Dispose of any resources that can be recreated.
  43. }
  44.  
  45. {"jsonrpc":"2.0","id":1,"result":[0,{"ubus_rpc_session":"07e111d317f7c701dc4dfde1b0d4862d","timeout":300,"expires":300,"acls":{"access-group":{"superuser":["read","write"],"unauthenticated":["read"]},"ubus":{"*":["*"],"session":["access","login"]},"uci":{"*":["read","write"]}},"data":{"username":"root"}}]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement