Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS - upload picture with ImageShack JSON API
    primarykey
    data
    text
    <p>I'm trying to upload a picture to ImageShack using their <a href="https://code.google.com/p/imageshackapi/wiki/ImageshackAPI" rel="noreferrer">API</a>:</p> <pre><code>- (void)uploadImage2:(UIImage *)image { NSData *imageToUpload = UIImagePNGRepresentation(image); if (imageToUpload) { NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init]; [parameters setObject:@"XXXX" forKey:@"key"]; [parameters setObject:@"json" forKey:@"format"]; //[parameters setObject:@"application/json" forKey:@"Content-Type"]; AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"https://post.imageshack.us"]]; NSMutableURLRequest *request = [client multipartFormRequestWithMethod:@"POST" path:@"/upload_api.php" parameters:parameters constructingBodyWithBlock: ^(id &lt;AFMultipartFormData&gt;formData) { [formData appendPartWithFileData: imageToUpload name:@"image" fileName:@"logo.png" mimeType:@"image/png"]; }]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *jsons = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil]; NSLog(@"response: %@",jsons); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { if([operation.response statusCode] == 403) { //NSLog(@"Upload Failed"); return; } //NSLog(@"error: %@", [operation error]); }]; [operation start]; } } </code></pre> <p>As a response I get error message back with no error explanations:</p> <pre><code>{ "error_code" = "upload_failed"; "error_message" = "Upload failed"; status = 0; } </code></pre> <p>Can anyone help me with that? What is the proper way to do it? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload