0

Working on iPhone app that takes a photo and then uploads it to a server. The server is in working condition, tested the same by uploading image from android app.

Below is the code snippet

NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",   FORM_BOUNDARY];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setHTTPShouldHandleCookies:NO];

[request setHTTPMethod:@"POST"];

[request setValue:contentType forHTTPHeaderField:@"Content-Type"];

[request setValue:[NSString stringWithFormat:@"%d", [data length]] forHTTPHeaderField:@"Content-Length"]

[request setHTTPBody:data];` 
////

But i get following response from the sever

HTTP Status 600 - java.lang.NullPointerException

type Status report

message java.lang.NullPointerException

description Cannot find message associated with key http.600

Apache Tomcat/6.0.18
////

I suppose error 600 might be user defined. Is there some tag being missed? Please suggest.

Nekto
  • 17,837
  • 1
  • 55
  • 65
Rohit
  • 6,941
  • 17
  • 58
  • 102

1 Answers1

1

As you wrote it is server error: HTTP Status 600 - java.lang.NullPointerException.

Moreover http status code >= 400 means that there are now problems in your request but there are problems on server side.

If you are server admin - try to debug server, for example, print post arguments.

I don't see problems in posted obj-C code.

P.S. I could just advice you to use highly populated ASIHttpRequest framework. It could handle file upload by itself. It is very easy and safe to use it.

Nekto
  • 17,837
  • 1
  • 55
  • 65
  • 1
    The author of ASIHTTPRequest recommends that nobody use it for new development. http://allseeing-i.com/[request_release]; –  Apr 28 '12 at 14:30
  • @GrahamLee could you please provide valid url? – Nekto Apr 28 '12 at 15:18
  • I did, unfortunately StackOverflow mangles it. The semicolon is part of the URL. –  Apr 28 '12 at 16:07
  • ">= 400 means that there are now problems in your request but there are problems on server side" It's not true. 4xx statuses are related to client request. 5xx statuses are related to the server issues. – NHG Nov 10 '21 at 09:20