Click here to Skip to main content
15,904,638 members
Home / Discussions / iOS


AnswerRe: GPS background tracking app Pin
Super Lloyd18-Jul-16 14:31
Super Lloyd18-Jul-16 14:31 
QuestionHow to call json WebService in iOS using swift.? Pin
mbatra3114-Jul-16 23:15
mbatra3114-Jul-16 23:15 
AnswerRe: How to call json WebService in iOS using swift.? Pin
Richard MacCutchan15-Jul-16 1:11
mveRichard MacCutchan15-Jul-16 1:11 
QuestionHow to call jSON web service from an iOS app..? Pin
mbatra3112-Jul-16 2:27
mbatra3112-Jul-16 2:27 
AnswerRe: How to call jSON web service from an iOS app..? Pin
Richard MacCutchan12-Jul-16 5:31
mveRichard MacCutchan12-Jul-16 5:31 
Questionusing nsNotificationenter Pin
Member 1259993223-Jun-16 0:15
Member 1259993223-Jun-16 0:15 
AnswerRe: using nsNotificationenter Pin
Super Lloyd12-Jul-16 17:47
Super Lloyd12-Jul-16 17:47 
QuestionHow to encode pdf file in UTF8 to for multipart http post Pin
rdediana18-Jun-16 3:43
rdediana18-Jun-16 3:43 

i've had success using python in creating a multipart http post upload of a pdf file to a web service, however, i'm having a challenge achieving the same outcome with objectivec

i'm using xcode 7.3 / iOS target version 9.3.

when i look at the encoded file data within the python multipart POST it looks like the below.

what would be the best process to load a PDF file from an IOS device and encode to UTF8 and submit an HTTP Multipart POST?

the method i've crated is also listed below, however, the encoded file data does seem to be correct.

<pre lang="objc">- (void)submitPackageJSONv4:(NSDictionary*)json document:(NSData*)document {
    // prepare multipart boundary
    NSString *boundary = @"unique-consistent-string";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
    // ---- initialize request object ----
    NSMutableURLRequest *request =
    [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@""]];
    [request setHTTPMethod:@"POST"];
    // ---- set headers ----
    [request setValue:@"Basic enVyZ1A3Y.........eW94b0U4Tw==" forHTTPHeaderField: @"Authorization"];
    [request setValue:@"gzip, deflate" forHTTPHeaderField: @"Accept-Encoding"];
    [request setValue:@"*/*" forHTTPHeaderField: @"Accept"];
    [request setValue:@"keep-alive" forHTTPHeaderField: @"Connection"];
    [request setValue:@"chunked" forHTTPHeaderField: @"Transfer-Encodinge"];
    [request setValue:contentType forHTTPHeaderField: @"Content-Type"];
    NSMutableData *body = [NSMutableData data];
    // ---- apppend JSON ----
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"%@\r\n", @"Content-Disposition: form-data; name='payload'"]
    [body appendData:[NSKeyedArchiver archivedDataWithRootObject:json]];
    // ---- apppend docs ----
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSASCIIStringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"%@\r\n", @"Content-Disposition: form-data; name='file'; filename='file'"]
    [body appendData:document];
    [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    // ---- set HTTP Body ----
    [request setHTTPBody:body];
    // ---- set the content-length header ----
    NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[body length]];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    // ---- send HTTP POST ----
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
        NSLog(@"%@", error.description);
        if(data.length > 0)

i've tried, if feels like, almost everthing without success.

any assistance would be greatly appreciated.

Content-Disposition: form-data; name="file"; filename="file"

4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
x+TT(T0P0��32544R0bscS=Ks��T�p�<��Ԣ�Ԃ�����L�z�" �+D������k���4:

QuestionBest iOS framework for animation ? Pin
Michael Pauli24-May-16 1:41
Michael Pauli24-May-16 1:41 
AnswerRe: Best iOS framework for animation ? Pin
Robert Yank13-Jul-16 22:35
Robert Yank13-Jul-16 22:35 
QuestionIs a front-end for FaceTime possible? Pin
Frank Alviani31-Aug-15 9:36
Frank Alviani31-Aug-15 9:36 
AnswerRe: Is a front-end for FaceTime possible? Pin
Dennis E White13-Oct-15 6:50
professionalDennis E White13-Oct-15 6:50 
AnswerRe: Is a front-end for FaceTime possible? Pin
Member 1207320820-Oct-15 3:01
Member 1207320820-Oct-15 3:01 
QuestionGoogle Map iOS Sdk with Navigation Speech Pin
Gaurav.p81013-Jul-15 19:18
Gaurav.p81013-Jul-15 19:18 
AnswerRe: Google Map iOS Sdk with Navigation Speech Pin
Dennis E White14-Jul-15 13:42
professionalDennis E White14-Jul-15 13:42 
QuestionHow to Convert UIView to PDF format? Pin
Member 1163171131-May-15 23:45
Member 1163171131-May-15 23:45 
AnswerRe: How to Convert UIView to PDF format? Pin
Richard MacCutchan1-Jun-15 0:45
mveRichard MacCutchan1-Jun-15 0:45 
AnswerRe: How to Convert UIView to PDF format? Pin
Dennis E White3-Jun-15 5:05
professionalDennis E White3-Jun-15 5:05 
QuestionNot able to receive notifications on device Pin
Member 1172504527-May-15 23:18
Member 1172504527-May-15 23:18 
AnswerRe: Not able to receive notifications on device Pin
Dennis E White4-Jun-15 5:04
professionalDennis E White4-Jun-15 5:04 
QuestioniOS app promotion code Pin
furkanavcu26-Apr-15 5:08
professionalfurkanavcu26-Apr-15 5:08 
QuestionIOS Pin
Member 1147575824-Feb-15 2:01
Member 1147575824-Feb-15 2:01 
AnswerRe: IOS Pin
Richard MacCutchan24-Feb-15 3:14
mveRichard MacCutchan24-Feb-15 3:14 
AnswerRe: IOS Pin
ZurdoDev24-Feb-15 4:57
professionalZurdoDev24-Feb-15 4:57 
QuestionSQl Server Database translator Pin
Member 1136485111-Feb-15 3:20
Member 1136485111-Feb-15 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.