(Objective-C) Example: Http.HttpNoBody method
Demonstrates how to use the HttpNoBody method to send HTTP requests without a request body (e.g., GET, DELETE, HEAD) and receive the response in a Chilkat Http response object. Note: This example requires Chilkat v11.0.0 or greater.
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <NSString.h>
BOOL success = NO;
CkoHttp *http = [[CkoHttp alloc] init];
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
// Send a DELETE request to https://api.example.com/users/123
NSString *url = @"https://api.example.com/users/123";
success = [http HttpNoBody: @"DELETE" url: url response: resp];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%@%d",@"Response Status Code: ",[resp.StatusCode intValue]);
NSLog(@"%@",@"Response body:");
NSLog(@"%@",resp.BodyStr);
|