Objective-C
Objective-C
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat Objective-C Downloads
#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <NSString.h>
BOOL success = NO;
CkoRest *rest = [[CkoRest alloc] init];
BOOL bTls = YES;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"example.com" port: [NSNumber numberWithInt: 443] tls: bTls autoReconnect: bAutoReconnect];
if (success == NO) {
NSLog(@"%@",rest.LastErrorText);
return;
}
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
CkoStringBuilder *sbResponse = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/api/items/123" sb: sbResponse];
if (success == NO) {
NSLog(@"%@",rest.LastErrorText);
return;
}
NSString *responseText = [sbResponse GetAsString];
if (sbResponse.LastMethodSuccess == NO) {
NSLog(@"%@",sbResponse.LastErrorText);
return;
}
NSLog(@"%@",responseText);