Sample code for 30+ languages & platforms
Objective-C

qa.factura1.com.co Obtain Auth Token

See more HTTP Misc Examples

Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co

Chilkat Objective-C Downloads

Objective-C
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

BOOL success = NO;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];

// Build the following JSON
// {
//   "password": "MY_PASSWORD",
//   "username": "MY_USERNAME"
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
json.EmitCompact = NO;
[json UpdateString: @"password" value: @"MY_PASSWORD"];
[json UpdateString: @"username" value: @"MY_USERNAME"];

CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpJson: @"POST" url: @"https://qa.factura1.com.co/v2/auth" json: json contentType: @"application/json" response: resp];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

CkoJsonObject *jsonResp = [[CkoJsonObject alloc] init];
jsonResp.EmitCompact = NO;
[jsonResp Load: resp.BodyStr];

NSLog(@"%@",[jsonResp Emit]);

NSLog(@"%@%@",@"Access token: ",[jsonResp StringOf: @"token"]);