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 .csv suffix or ?format=csv
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: text/csv
Content-Type: text/csv
Content-Length: length
{"username":"String","password":"String","accessToken":"String"}