in Education by
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; } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Error 3840 ... Invalid value around character 0. simply means that the (JSON) string is empty, you got nothing from the server. To get NSData from a string there is a more convenient API: NSData *myRequestData = [postString dataUsingEncoding:NSUTF8StringEncoding]; Actually a base64 formatted string is not JSON as specified in the header. That might cause the problem. PS: Don't use synchronous – deprecated – API to load data over the network

Related questions

0 votes
    I have a table of items with a checkmark disclosure button, and I want to create a second table ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have to download images to my iOS apps local file system and read them back. On my simulator I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I am trying to get a thumbnail image from a video from a URL using AVFoundation but I am getting ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I replaced the Google Analytics SDK with the Firebase SDK. I'm looking to generate some of the previously- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    in Obj-C it was possible to iterate through alphabet with: for (char x='A'; x...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    i am new to iphone app development.i am trying to connect facebook using the facebook api's using iphone ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I have a single view in my application which does not receive any events from iOS. I tried to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    I'm working on VS 2005 and something has gone wrong on my machine. Suddenly, out of the blue, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Does anyone know how to solve this java error? java.io.IOException: Invalid keystore format I get it when ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Does anyone know how to solve this java error? java.io.IOException: Invalid keystore format I get it when ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I get "Login failed error" with the Facebook Android SDK while running on the device. I have done ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I am trying develop first app in ionic and with codeigniter backend but facing Response for preflight has ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    Choose the final value of c from the following code, when, int a=12, b=13, c=0; c=a+++++a/7+b++; * Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
...