(Objective-C) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body. Note: This example requires Chilkat v11.0.0 or greater.
#import <CkoHttp.h>
#import <NSString.h>
#import <CkoHttpResponse.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
// Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
NSString *requestBody = @"{ \"abc\": 123 }";
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpStr: @"DELETE" url: @"https://example.com/something" bodyStr: requestBody charset: @"utf-8" contentType: @"application/json" response: resp];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%@%d",@"Response status: ",[resp.StatusCode intValue]);
NSLog(@"%@",@"Response body: ");
NSLog(@"%@",resp.BodyStr);
|