Error: cocoa error 3840

false

when using AFNetworking POST to connect to WEB API, error:
“The operation couldn’t e completed. (Cocoa error 3840).”

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=0x1667f670 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

solution

this is a JSON parsing error, which in general is probably caused by the incorrect format of the JSON data returned by your WEB API.

therefore, make sure that the return value of the WEB API is in the correct and valid JSON format. You can check with the following online JSON validation tool.

recommendation article: network requests and various error Code summary (Errors Code)

Read More: