I have a strange issue while getting response from SVC webservice.
I have a response as below:
When I am fetching content from "AboutOrganization" key.
I am getting error as below:-
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Something looked like a 'null' but wasn't around character 324840.) UserInfo=0xc52345b0 {NSDebugDescription=Something looked like a 'null' but wasn't around character 324840.}
I have used NSJSONSerialization to get data from Webservice response.
I am not sure, But getting this type of Error because JSON object contents HTML escape sequence characters as below:
If I am right then give me solution for the same. And If i am wrong then guide me why i am getting this type of error.
Appreciate your time and help
Thank you in advance.
Related
Please tell how to solve this error and it is server side error or error in code or problem in json data(response)
Error: 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=0x7fd4484df340 {NSDebugDescription=JSON text did not start
with array or object and option to allow fragments not set.,
NSUnderlyingError=0x7fd448488120 "Request failed: internal server
error (500)"}
Look at the line: "Request failed: internal server error (500)". Then google for "Status 500". That should answer your question.
Once you actually get a useful response from the server and you run into this error 3840, search for error 3840 which has about 1000 answers.
Am trying to integrate instagram in my app,while getting user details after getting access token,its showing error . Am appending data in NSData and trying to print it in connectionDidFinishLoading(NSURLConnection *)connection ( NSURLConnection Delegate) . While converting NSData to id ,its showing null .Also if i am converting NSdata to NSString am getting Response as
{"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"The access_token provided is invalid."}}{"meta":{"code":200},"data":{"username":"XXXX","bio":"","website":"","profile_picture":"http:sampleiamge.jpg","full_name":"samplename","counts":{"media":1,"followed_by":0,"follows":0},"id":"sampleID"}}
If am printing the json as id jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
getting error as
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be
completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0xa967bc0
{NSDebugDescription=Garbage at end.}
Tried all jsonreading option ,but no result
Any hep will be appreciable.
Thanks
You could also have a look at the InstagramKit which does this fairly straight forward. https://github.com/shyambhat/InstagramKit
There's a demo app so you can see how the authentication is done and request a user's details in just a few lines of code. You don't really need to mess around with the access token data format.
It seems like you are not authenticate.
There is a project in GitHub that implements a simple UIViewController that performs the Instagram auth process step by step:
https://github.com/Buza/Instagram-Auth-iOS
You can see all process from request token to error management.
Hope it helps!
The response occurs when the access_token is invalid, try printing (NSLog) out the URL your are making the request and make sure the access_token is correctly passed.
I have problem with xml parsing
I got an XML response from the server with this header:
?xml version="1.0"?
So I can't parse it and I can't get my attribute values. In same structure static I will parse else it won't work .
If i add my header file statically like this ?xml version=\"1.0\" encoding=\"UTF-8\"? it will work fine .
However if I dynamically append this "encoding=\"UTF-8\" in my xml it shows an error
Parser error Error Domain=NSXMLParserErrorDomain Code=64 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 64.)"
see the full xml file
I am trying to use: checkResourceIsReachableAndReturnError of NSURL class
But I always get FALSE and the NSError shows : Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)"
I checked the URL with safary and it works, any idea?
This is not the method you are looking for. The description of the method in NSURL's class reference states:
Returns whether the resource pointed to by a file URL can be reached.
The method should be used to test reachability of file URLs, you cannot check whether an internet resource is available or not using this method.
You'll find several answers in stack overflow if you search for reachability testing or something similar.. However, you could probably just attempt to reach the URL and handle the error if that fails.
I request a JSON response from a home controlling device:
NSData* responseData = [NSData dataWithContentsOfURL:url];
The JSON data in responseData is complete and valid. However, if I try
NSDictionary* dict = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSLog("Error: %#", error);
it gives me the following error:
Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Duplicate key for object around character 0.) UserInfo=0x6a8b8e0 {NSDebugDescription=Duplicate key for object around character 0.}
I searched the web but couldn't find anything helpful so far.
Edit: The JSON response it quite long, so instead of posting it here, please find it here.
It looks like the JSON is fine by pasting it into http://jsonformat.com/ - maybe you found an Apple bug? Another way to try and validate would be to use a third-party iOS library and see if it gives you the same error? Say, TouchJSON?
I get the same error, only at random when the app runs. When the NSJSONSerialization fails I've checked the json object it chocks on using a JSON Viewer. The JSON is always OK. Bugs in NSJSONSerialization when it's called several times?
I got the same error. My JSON data passed JSON validator at http://jsonformatter.curiousconcept.com/ . However, I found two duplicated keys in my JSON (at the end of dictionary). After I removed those keys, NSJSONSerialization works smoothly.