How can I return the user ID from my Drupal 7 REST services after my IOS swift Xcode7 API registers a user to my site? The console returns a status 200 (OK) but not the UID registered, which I will need for further functions. What further lines of code do I need to include here, or can I add as a separate API?
Here is my code:
import UIKit
import Foundation
import Alamofire
import SwiftyJSON
class submitVoteViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
print("loaded page1")
}
@IBAction func register(sender: AnyObject) {
// register user
let voteEndpoint: String = "https://www.example.com/ios1/user/register.json"
let newVote = ["account":["name":"example name", "mail":"examplemail@gmail.com", "pass":"examplepass", "status":1]]
Alamofire.request(.POST, voteEndpoint, parameters: newVote, encoding: .JSON)
.response { request, response, data, error in
print(request)
print (response)
print (error)
}
}
When i look it up, the Drupal site shows me the UID is 375 (blocked, though I had entered status 1 so that the user would be active?) . The console response is;
loaded page1 Optional( { URL: https://www.example.com/ios1/user/register.json }) Optional( { URL: https://www.example.com/ios1/user/register.json } { status code: 200, headers { "Cache-Control" = "no-cache, must-revalidate"; Connection = "Keep-Alive"; "Content-Type" = "application/json"; Date = "Sat, 16 Jul 2016 23:03:37 GMT"; Expires = "Sun, 19 Nov 1978 05:00:00 GMT"; "Keep-Alive" = "timeout=10, max=200"; Server = Apache; "Set-Cookie" = "DRUPAL_UID=0; expires=Fri, 15-Jul-2016 23:03:37 GMT; Max-Age=-86401; path=/; domain=.example.com; secure, DRUPAL_UID=-1; expires=Tue, 09-Aug-2016 02:36:57 GMT; Max-Age=1999999; path=/; domain=.example.com; secure"; "Transfer-Encoding" = Identity; "X-Content-Type-Options" = nosniff; "X-Powered-By" = "PHP/5.6.9"; } }) nil