I am trying to upload image by converting image to base64 format. And i am getting below error.
Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
Please refer my code
NSData *imageData = UIImagePNGRepresentation(image); NSString *imageDataString = [imageData base64EncodedString];
Here is the Post request method
- (id) postRequest:(NSURL *)postURL postString:(NSString *)postString { NSError * error=nil; NSURLResponse * urlResponse; NSData *myRequestData = [ NSData dataWithBytes: [ postString UTF8String ] length: [ postString length ]]; NSMutableURLRequest * request =[[NSMutableURLRequest alloc]initWithURL:postURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; [request setHTTPBody: myRequestData]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; NSData * data =[NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]; if (!data) { return nil; } id jsonnResponse =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; return jsonnResponse; }