Sample code for 30+ languages & platforms
Objective-C Requires Chilkat v11.0.0+

Transition from Http.PostJson3 to Http.HttpJson

Provides instructions for replacing deprecated PostJson3 method calls with HttpJson.

Chilkat Objective-C Downloads

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

BOOL success = NO;

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

NSString *url = @"https://example.com/something";
NSString *contentType = @"application/json";
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json LoadFile: @"C:/temp/requestBody.json"];

//  ------------------------------------------------------------------------
//  The PostJson3 method is deprecated:

CkoHttpResponse *responseObj = [http PostJson3: url contentType: contentType json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

//  ...
//  ...

//  ------------------------------------------------------------------------
//  Do the equivalent using HttpJson.
//  Your application creates a new, empty HttpResponse object which is passed 
//  in the last argument and filled upon success.

CkoHttpResponse *responseOut = [[CkoHttpResponse alloc] init];
success = [http HttpJson: @"POST" url: url json: json contentType: contentType response: responseOut];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}