Skip to content

How to get json returned when server response is 422 ? #53

@ntkon

Description

@ntkon

Hi,
I'm calling a rest api and the server is returning server response 422, but the error I'm getting in the onError block shows 'unknown' with message '-1 - Unknown'

The log shows:

200 'https://myapi.com/'
responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}))

When I run the api in swagger the json returned is:

{
  "message": "The selected email is invalid.",
  "errors": [
    {
      "name": "email",
      "desc": "The selected email is invalid."
    }
  ]
}

and the headers shown are:

 access-control-allow-credentials: true 
 access-control-allow-headers: X-Platform, Content-Type, X-Auth-Token, Origin, Authorization, X-Requested-With, x-xsrf-token 
 access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS 
 access-control-allow-origin: http://subbyfinder.naamtechstaging.com 
 cache-control: no-cache, private 
 connection: keep-alive 
 content-type: application/json 
 date: Wed, 20 Jun 2018 05:04:23 GMT 
 server: nginx/1.10.3 (Ubuntu) 
 transfer-encoding: chunked 

Thanks,
WS is great and thanks for all your efforts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions