0

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)"}

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
Birendra
  • 623
  • 1
  • 5
  • 17
  • 1
    Possible duplicate of [Cocoa error 3840 using JSON (iOS)](http://stackoverflow.com/questions/14171111/cocoa-error-3840-using-json-ios) – vadian Nov 25 '15 at 13:36
  • 1
    Not really a duplicate, because the problem has nothing to do with JSON. – gnasher729 Nov 25 '15 at 13:39

1 Answers1

2

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.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • 1
    You didn't get a valid JSON response. So you got an error for trying to parse an invalid JSON response. But that's not the cause of the problem. The problem is caused by the server telling you "internal server error". Which _may_ in turn be caused by you sending a rubbish request to the server. So no reason to look at the JSON at this point. – gnasher729 Nov 25 '15 at 13:45
  • I am using php web-service and app is work good but suddenly this error occurs so the error is php side? – Birendra Nov 25 '15 at 13:48
  • 1
    Do the words "internal **server** error" not mean anything to you? – Avi Nov 25 '15 at 14:17
  • @Birendra The *server* says that there is a *server* error (code: 500). However, it is possible that you send a request that is that corrupted that the server detects an internal error. (Should not be this way, but in practice …) However, it is likely that something is wrong with the server. – Amin Negm-Awad Nov 26 '15 at 05:47