Note that there are some explanatory texts on larger screens.

plurals
  1. POAFNetworking : upload image with other parameters
    primarykey
    data
    text
    <p>First of all, thank you for read this question.</p> <p>I am developing app which is using JSON webservice. In the app, I need to call webservice with image (profile Image) with some parameters. My JSON request should be same as following...</p> <pre><code>{ "adduser": { "firstname": "testFirstName", "lastname": "testLastName", "email": "test@test.com", "projectids" : "1" } } </code></pre> <p>there is other variable as <code>profileimage</code> for uploading image.</p> <p>I have write following code.</p> <pre><code> NSDictionary *dictParameter = @{@"adduser": @{@"firstname": firstName, @"lastname":lastName,@"email":email, @"projectids":@"1"}}; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; AFHTTPRequestOperation *op = [manager POST:strURL parameters:dictParameter constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt; formData) { } success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Success: %@ ***** %@", operation.responseString, responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@ ***** %@", operation.responseString, error); }]; [op start]; </code></pre> <p>Above code log following error.</p> <pre><code>Error: &lt;br /&gt; &lt;b&gt;Notice&lt;/b&gt;: Undefined index: json in &lt;b&gt;/opt/lampp/htdocs/testproject/app/webroot/webservices/include.php&lt;/b&gt; on line &lt;b&gt;15&lt;/b&gt;&lt;br /&gt; {"status":"failure","message":"Your Request is Empty"} ***** Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8abe490 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} </code></pre> <p>If i use following code than it work fine. But i am not able to upload image.</p> <pre><code>AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:strURL parameters:dictParameter success:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }]; </code></pre> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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