POST | /api/users/token |
---|
import Foundation
import ServiceStack
public class LoginRequest : LoginResponse, IPost
{
public var username:String?
public var password:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case username
case password
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
username = try container.decodeIfPresent(String.self, forKey: .username)
password = try container.decodeIfPresent(String.self, forKey: .password)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if username != nil { try container.encode(username, forKey: .username) }
if password != nil { try container.encode(password, forKey: .password) }
}
}
public class LoginResponse : Codable
{
public var accessToken:String?
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/users/token HTTP/1.1
Host: accounts.dev.healthmonix.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<LoginRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Hmx.Accounts.ServiceInterfaces">
<AccessToken>String</AccessToken>
<Password>String</Password>
<Username>String</Username>
</LoginRequest>