0

I'm trying to figure out how I can do a PUT request to my backend, with in the URL a base 64 image and some other parameters.

this is the code I'm using:

                NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"mywebservice/api/appearances/%@?name=%@&fontsize=%@&logo=%@&active=%@",app.id,app.name,app.fontsize,[app.logoimage base64EncodedString],app.active]];

                NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL
                                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                                   timeoutInterval:30.0];
                NSLog(@"de url ziet er zo uit: %@", URL);
                [request setHTTPMethod:@"PUT"];

                NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
                [connection start];

When I replace the long base 64 image string by a short random String it works.

Anyone who knows what can be the reason?

Thanks!

rendered url: http://cl.ly/0j2p1R2Q0w36

1
  • Have you tried multipart? Commented May 18, 2013 at 9:13

1 Answer 1

1

You need to use a POST request as the maximum length of a URL is something like 2000 characters.

Here is a good SO question which should give you clues on how to implement the POST request.

Sign up to request clarification or add additional context in comments.

2 Comments

I guess my problem here is then that I'm using grails as the backend service, and I can't figure out how I can get the HTTP body instead of just the parameters in the POST/SAVE method.
@leke That sounds like another question you might like to ask here (or simply search for the question as it's almost certainly already been answered).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.