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

Azure Table: Atomically Merge and Delete Entities

See more Azure Table Service Examples

Reads two entities and captures their exact ETags, then submits a conditional MERGE for one and DELETE for the other. Concurrent changes fail the whole changeset. Disabled by default. Uses exactly two entities with one fixed table/partition, unique Content-IDs, CRLF multipart framing, and a byte-count check against the 4 MiB request limit. Dynamic batches must additionally preserve the 100-operation, single-partition and unique-entity constraints.

Parses nested MIME responses using Chilkat.Mime, validates inner HTTP status and Content-ID uniqueness/completeness, and requires 204 for both operations. Outer 202 alone is not success. A lost or malformed response has an uncertain outcome; inspect state before replaying. Separate batches are not atomic together.

Targets Azure Storage Table service in the public cloud, not Azure Cosmos DB for Table. Uses Chilkat 11.6.0 or later and an unlocked library. Direct data requests pin x-ms-version 2026-04-06 and OData 3.0. Shared Key examples read private qa_data/azure/storage.json with account and access_key string fields. Authentication examples explain their additional fields. Create private local directories before running; keep credentials, tokens, SAS, entity values, checkpoints and diagnostics outside public content and source control.

HTTPS certificates are verified. Transport completion and HTTP status are checked separately. Writes are not automatically retried after an uncertain outcome. Entity keys, ETags and continuation tokens remain strings. Examples operate on the existing ExampleCustomers table unless noted; review the targets before adapting them. Microsoft Entra ID with suitable Table data roles is preferred where available.

Microsoft reference.

Chilkat Objective-C Downloads

Objective-C
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
#import <CkoRest.h>
#import <CkoAuthAzureStorage.h>
#import <CkoSocket.h>
#import <CkoPrng.h>
#import <CkoBinData.h>
#import <CkoMime.h>
#import <CkoHashtable.h>

BOOL success = NO;

//  StringBuilder compares text by value in every generated language.
CkoStringBuilder *textCompare = [[CkoStringBuilder alloc] init];
BOOL applyChange = NO;
if (applyChange != YES) {
    NSLog(@"%@",@"This example writes an atomic transaction. Review the target and deliberately enable applyChange.");
    return;
}

//  Assumes Chilkat is unlocked. See Global Unlock Sample.
success = NO;
CkoJsonObject *config = [[CkoJsonObject alloc] init];
config.Strict = YES;
success = [config LoadFile: @"qa_data/azure/storage.json"];
if (success != YES) {
    NSLog(@"%@",@"Could not load private Azure configuration.");
    return;
}

[textCompare Clear];
[textCompare SetString: [config StringOf: @"account"]];
BOOL sameText1 = [textCompare ContentsEqual: @"" caseSensitive: YES];
if (([[config JsonTypeOf: @"account"] intValue] != 1) || (sameText1 == YES)) {
    NSLog(@"%@",@"Supply the storage account name.");
    return;
}

//  access_key is the base64 account key, not a connection string or SAS.
[textCompare Clear];
[textCompare SetString: [config StringOf: @"access_key"]];
BOOL sameText2 = [textCompare ContentsEqual: @"" caseSensitive: YES];
if (([[config JsonTypeOf: @"access_key"] intValue] != 1) || (sameText2 == YES)) {
    NSLog(@"%@",@"Supply the base64 account access key.");
    return;
}

CkoStringBuilder *accountText = [[CkoStringBuilder alloc] init];
success = [accountText Append: [config StringOf: @"account"]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

if (([accountText.Length intValue] < 3) || ([accountText.Length intValue] > 24)) {
    NSLog(@"%@",@"Storage account names need 3-24 lowercase letters or digits.");
    return;
}

CkoStringBuilder *allowedAccountChars = [[CkoStringBuilder alloc] init];
success = [allowedAccountChars Append: @"abcdefghijklmnopqrstuvwxyz0123456789"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

int charIndex = 0;
while ((charIndex < [accountText.Length intValue])) {
    if ([allowedAccountChars Contains: [accountText GetRange: [NSNumber numberWithInt: charIndex] numChars: [NSNumber numberWithInt: 1] removeFlag: NO] caseSensitive: YES] != YES) {
        NSLog(@"%@",@"Storage account names need lowercase letters or digits.");
        return;
    }

    charIndex = charIndex + 1;
}

CkoStringBuilder *endpoint = [[CkoStringBuilder alloc] init];
success = [endpoint Append: [config StringOf: @"account"]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [endpoint Append: @".table.core.windows.net"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

//  Table names contain only letters and digits and are case-insensitive.
//  Entity PartitionKey and RowKey values are case-sensitive.
NSString *resourcePath = @"/$batch";
CkoRest *rest = [[CkoRest alloc] init];
rest.ConnectTimeoutMs = [NSNumber numberWithInt:20000];
rest.IdleTimeoutMs = [NSNumber numberWithInt:60000];
CkoAuthAzureStorage *azAuth = [[CkoAuthAzureStorage alloc] init];
azAuth.Account = [config StringOf: @"account"];
azAuth.AccessKey = [config StringOf: @"access_key"];
azAuth.Service = @"Table";
azAuth.Scheme = @"SharedKey";
azAuth.XMsVersion = @"2026-04-06";
success = [rest SetAuthAzureStorage: azAuth];
if (success != YES) {
    NSLog(@"%@",@"Could not configure Shared Key signing.");
    return;
}

CkoSocket *connection = [[CkoSocket alloc] init];
connection.RequireSslCertVerify = YES;
connection.MaxReadIdleMs = [NSNumber numberWithInt:60000];
connection.MaxSendIdleMs = [NSNumber numberWithInt:60000];
success = [connection Connect: [endpoint GetAsString] port: [NSNumber numberWithInt: 443] ssl: YES maxWaitMs: [NSNumber numberWithInt: 20000]];
if (success != YES) {
    NSLog(@"%@",@"TLS connection failed; inspect diagnostics privately.");
    return;
}

//  Do not replay a write automatically after losing its response.
success = [rest UseConnection: connection autoReconnect: NO];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

NSString *responseText = 0;
CkoJsonObject *result = [[CkoJsonObject alloc] init];
result.Strict = YES;
success = [rest AddHeader: @"DataServiceVersion" value: @"3.0;NetFx"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [rest AddHeader: @"MaxDataServiceVersion" value: @"3.0;NetFx"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [rest AddHeader: @"Content-Type" value: @"application/json"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [rest AddHeader: @"Accept" value: @"application/json;odata=minimalmetadata"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

resourcePath = @"/ExampleCustomers(PartitionKey='customers-west',RowKey='customer-001')";
responseText = [rest FullRequestNoBody: @"GET" uriPath: resourcePath];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Request did not complete; inspect the target before retrying a write.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"HTTP status: ",[rest.ResponseStatusCode intValue]);
    NSLog(@"%@%@",@"Request ID: ",[rest ResponseHdrByName: @"x-ms-request-id"]);
    //  404 is missing, 409 is conflict, and 412 is a stale ETag: none are success.
    //  Keep response bodies private. Reconcile uncertain writes before retrying.
    return;
}

success = [result Load: responseText];
if (success != YES) {
    NSLog(@"%@",@"Expected well-formed JSON.");
    return;
}

[textCompare Clear];
[textCompare SetString: [result StringOf: @"PartitionKey"]];
BOOL sameText3 = [textCompare ContentsEqual: @"customers-west" caseSensitive: YES];
[textCompare Clear];
[textCompare SetString: [result StringOf: @"RowKey"]];
BOOL sameText4 = [textCompare ContentsEqual: @"customer-001" caseSensitive: YES];
if ((sameText3 != YES) || (sameText4 != YES)) {
    NSLog(@"%@",@"Unexpected entity in batch preflight.");
    return;
}

NSString *etag1 = [rest ResponseHdrByName: @"ETag"];
[textCompare Clear];
[textCompare SetString: etag1];
BOOL sameText5 = [textCompare ContentsEqual: @"" caseSensitive: YES];
[textCompare Clear];
[textCompare SetString: etag1];
BOOL sameText6 = [textCompare ContentsEqual: @"*" caseSensitive: YES];
if ((sameText5 == YES) || (sameText6 == YES)) {
    NSLog(@"%@",@"Batch needs exact entity ETags.");
    return;
}

[rest Disconnect: [NSNumber numberWithInt: 10]];
success = [connection Connect: [endpoint GetAsString] port: [NSNumber numberWithInt: 443] ssl: YES maxWaitMs: [NSNumber numberWithInt: 20000]];
if (success != YES) {
    NSLog(@"%@",@"TLS reconnection failed.");
    return;
}

success = [rest UseConnection: connection autoReconnect: NO];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

resourcePath = @"/ExampleCustomers(PartitionKey='customers-west',RowKey='customer-002')";
responseText = [rest FullRequestNoBody: @"GET" uriPath: resourcePath];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Request did not complete; inspect the target before retrying a write.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"HTTP status: ",[rest.ResponseStatusCode intValue]);
    NSLog(@"%@%@",@"Request ID: ",[rest ResponseHdrByName: @"x-ms-request-id"]);
    //  404 is missing, 409 is conflict, and 412 is a stale ETag: none are success.
    //  Keep response bodies private. Reconcile uncertain writes before retrying.
    return;
}

success = [result Load: responseText];
if (success != YES) {
    NSLog(@"%@",@"Expected well-formed JSON.");
    return;
}

[textCompare Clear];
[textCompare SetString: [result StringOf: @"PartitionKey"]];
BOOL sameText7 = [textCompare ContentsEqual: @"customers-west" caseSensitive: YES];
[textCompare Clear];
[textCompare SetString: [result StringOf: @"RowKey"]];
BOOL sameText8 = [textCompare ContentsEqual: @"customer-002" caseSensitive: YES];
if ((sameText7 != YES) || (sameText8 != YES)) {
    NSLog(@"%@",@"Unexpected entity in batch preflight.");
    return;
}

NSString *etag2 = [rest ResponseHdrByName: @"ETag"];
[textCompare Clear];
[textCompare SetString: etag2];
BOOL sameText9 = [textCompare ContentsEqual: @"" caseSensitive: YES];
[textCompare Clear];
[textCompare SetString: etag2];
BOOL sameText10 = [textCompare ContentsEqual: @"*" caseSensitive: YES];
if ((sameText9 == YES) || (sameText10 == YES)) {
    NSLog(@"%@",@"Batch needs exact entity ETags.");
    return;
}

[rest Disconnect: [NSNumber numberWithInt: 10]];
success = [connection Connect: [endpoint GetAsString] port: [NSNumber numberWithInt: 443] ssl: YES maxWaitMs: [NSNumber numberWithInt: 20000]];
if (success != YES) {
    NSLog(@"%@",@"TLS reconnection failed.");
    return;
}

success = [rest UseConnection: connection autoReconnect: NO];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

resourcePath = @"/$batch";
//  Exactly two distinct entities in the same table and partition, by construction.
//  Dynamic plans must also enforce <=100 operations, one operation per entity, and one partition.
CkoPrng *random = [[CkoPrng alloc] init];
NSString *nonce = [random GenRandom: [NSNumber numberWithInt: 16] encoding: @"hex"];
if (random.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Could not create MIME boundaries.");
    return;
}

CkoStringBuilder *batchBoundary = [[CkoStringBuilder alloc] init];
CkoStringBuilder *changesetBoundary = [[CkoStringBuilder alloc] init];
success = [batchBoundary Append: @"batch_"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [batchBoundary Append: nonce];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [changesetBoundary Append: @"changeset_"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [changesetBoundary Append: nonce];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

CkoStringBuilder *wire = [[CkoStringBuilder alloc] init];
success = [wire Append: @"--"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [batchBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\nContent-Type: multipart/mixed; boundary="];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [changesetBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\n\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [changesetBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID: 1\r\n\r\nMERGE https://"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [endpoint GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"/ExampleCustomers(PartitionKey='customers-west',RowKey='customer-001') HTTP/1.1\r\nAccept: application/json;odata=minimalmetadata\r\nDataServiceVersion: 3.0;NetFx\r\nMaxDataServiceVersion: 3.0;NetFx\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"If-Match: "];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: etag1];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

CkoJsonObject *item1 = [[CkoJsonObject alloc] init];
success = [item1 UpdateString: @"PartitionKey" value: @"customers-west"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [item1 UpdateString: @"RowKey" value: @"customer-001"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [item1 UpdateString: @"Address" value: @"Batch address 1"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"Content-Type: application/json\r\nPrefer: return-no-content\r\n\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [item1 Emit]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [changesetBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID: 2\r\n\r\nDELETE https://"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [endpoint GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"/ExampleCustomers(PartitionKey='customers-west',RowKey='customer-002') HTTP/1.1\r\nAccept: application/json;odata=minimalmetadata\r\nDataServiceVersion: 3.0;NetFx\r\nMaxDataServiceVersion: 3.0;NetFx\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"If-Match: "];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: etag2];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [changesetBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: [batchBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [wire Append: @"--\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

CkoBinData *payloadBytes = [[CkoBinData alloc] init];
success = [payloadBytes AppendString: [wire GetAsString] charset: @"utf-8"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

if ([payloadBytes.NumBytes intValue] > 4194304) {
    NSLog(@"%@",@"Batch exceeds the 4 MiB limit including multipart overhead.");
    return;
}

CkoStringBuilder *contentType = [[CkoStringBuilder alloc] init];
success = [contentType Append: @"multipart/mixed; boundary="];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [contentType Append: [batchBoundary GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [rest AddHeader: @"Content-Type" value: [contentType GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [rest AddHeader: @"Accept" value: @"multipart/mixed"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

responseText = [rest FullRequestString: @"POST" uriPath: resourcePath bodyText: [wire GetAsString]];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Request did not complete; inspect the target before retrying a write.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 202) {
    NSLog(@"%@%d",@"HTTP status: ",[rest.ResponseStatusCode intValue]);
    NSLog(@"%@%@",@"Request ID: ",[rest ResponseHdrByName: @"x-ms-request-id"]);
    //  404 is missing, 409 is conflict, and 412 is a stale ETag: none are success.
    //  Keep response bodies private. Reconcile uncertain writes before retrying.
    return;
}

//  Outer 202 only acknowledges the batch envelope, not transaction success.
CkoStringBuilder *responseMimeText = [[CkoStringBuilder alloc] init];
success = [responseMimeText Append: @"Content-Type: "];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [responseMimeText Append: [rest ResponseHdrByName: @"Content-Type"]];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [responseMimeText Append: @"\r\nMIME-Version: 1.0\r\n\r\n"];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

success = [responseMimeText Append: responseText];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

CkoMime *envelope = [[CkoMime alloc] init];
CkoMime *changeset = [[CkoMime alloc] init];
CkoMime *part = [[CkoMime alloc] init];
success = [envelope LoadMime: [responseMimeText GetAsString]];
if (success != YES) {
    NSLog(@"%@",@"Invalid MIME batch response; reconcile before retrying.");
    return;
}

[textCompare Clear];
[textCompare SetString: envelope.ContentType];
BOOL sameText11 = [textCompare ContentsEqual: @"multipart/mixed" caseSensitive: YES];
if ((sameText11 != YES) || ([envelope.NumParts intValue] != 1)) {
    NSLog(@"%@",@"Expected one changeset response.");
    return;
}

success = [envelope PartAt: [NSNumber numberWithInt: 0] subPart: changeset];
if (success != YES) {
    NSLog(@"%@",@"Could not prepare the request.");
    return;
}

[textCompare Clear];
[textCompare SetString: changeset.ContentType];
BOOL sameText12 = [textCompare ContentsEqual: @"multipart/mixed" caseSensitive: YES];
if ((sameText12 != YES) || ([changeset.NumParts intValue] < 1) || ([changeset.NumParts intValue] > 2)) {
    NSLog(@"%@",@"Invalid changeset response.");
    return;
}

CkoHashtable *responseIds = [[CkoHashtable alloc] init];
CkoStringBuilder *inner = [[CkoStringBuilder alloc] init];
CkoStringBuilder *statusLine = [[CkoStringBuilder alloc] init];
CkoMime *innerHeaders = [[CkoMime alloc] init];
int partIndex = 0;
while ((partIndex < [changeset.NumParts intValue])) {
    success = [changeset PartAt: [NSNumber numberWithInt: partIndex] subPart: part];
    if (success != YES) {
        NSLog(@"%@",@"Could not prepare the request.");
        return;
    }

    [textCompare Clear];
    [textCompare SetString: part.ContentType];
    BOOL sameText13 = [textCompare ContentsEqual: @"application/http" caseSensitive: YES];
    if (sameText13 != YES) {
        NSLog(@"%@",@"Expected application/http response part.");
        return;
    }

    success = [inner SetString: [part GetBodyDecoded]];
    if (success != YES) {
        NSLog(@"%@",@"Could not prepare the request.");
        return;
    }

    if ([inner Contains: @"\r\n\r\n" caseSensitive: YES] != YES) {
        NSLog(@"%@",@"Incomplete inner HTTP response.");
        return;
    }

    success = [statusLine SetString: [inner GetBefore: @"\r\n" removeFlag: YES]];
    if (success != YES) {
        NSLog(@"%@",@"Could not prepare the request.");
        return;
    }

    if ([statusLine StartsWith: @"HTTP/1.1 " caseSensitive: YES] != YES) {
        NSLog(@"%@",@"Invalid inner HTTP status line.");
        return;
    }

    success = [innerHeaders LoadMime: [inner GetAsString]];
    if (success != YES) {
        NSLog(@"%@",@"Invalid inner response headers.");
        return;
    }

    NSString *contentId = [innerHeaders GetHeaderField: @"Content-ID"];
    [textCompare Clear];
    [textCompare SetString: contentId];
    BOOL sameText14 = [textCompare ContentsEqual: @"1" caseSensitive: YES];
    [textCompare Clear];
    [textCompare SetString: contentId];
    BOOL sameText15 = [textCompare ContentsEqual: @"2" caseSensitive: YES];
    if ((sameText14 != YES) && (sameText15 != YES)) {
        NSLog(@"%@",@"Unexpected or missing response Content-ID.");
        return;
    }

    if ([responseIds Contains: contentId] == YES) {
        NSLog(@"%@",@"Duplicate response Content-ID.");
        return;
    }

    success = [responseIds AddStr: contentId value: @"seen"];
    if (success != YES) {
        NSLog(@"%@",@"Could not prepare the request.");
        return;
    }

    [textCompare Clear];
    [textCompare SetString: [statusLine GetNth: [NSNumber numberWithInt: 1] delimiterChar: @" " exceptDoubleQuoted: NO exceptEscaped: NO]];
    BOOL sameText16 = [textCompare ContentsEqual: @"204" caseSensitive: YES];
    if (sameText16 != YES) {
        NSLog(@"%@%@",@"Atomic transaction did not report success. Operation Content-ID: ",contentId);
        NSLog(@"%@%@",@"Inner HTTP status: ",[statusLine GetNth: [NSNumber numberWithInt: 1] delimiterChar: @" " exceptDoubleQuoted: NO exceptEscaped: NO]);
        //  Keep the full error body private. A service-reported operation failure rolls back the changeset.
        return;
    }

    partIndex = partIndex + 1;
}

if (([changeset.NumParts intValue] != 2) || ([responseIds Contains: @"1"] != YES) || ([responseIds Contains: @"2"] != YES)) {
    NSLog(@"%@",@"Incomplete success response; inspect state before replaying.");
    return;
}

NSLog(@"%@",@"Both operations succeeded in one atomic transaction.");