I am having issues parsing the response from an API call using Siesta for iOS. After I post the JSON, it fails trying to parse the response.
resource("/SaveEmailAddress").request(.post, json: SaveEmailAddress.toDictionary()).onSuccess { (entity) in
completion(entity, nil)
}.onFailure{ (error) in
completion(nil, error)
}
The API is only returning "Success" in the body.
:status: 200
cache-control: private
content-type: application/json; charset=utf-8
server: Microsoft-IIS/10.0
x-aspnet-version: 4.0.30319
x-powered-by: ASP.NET
date: Tue, 23 Oct 2018 03:35:42 GMT
content-length: 9
"Success"
It is my understanding that "Success" is valid JSON, however, because it is not an array or a dictionary, Siesta is throwing a "Cannot parse server response" error.
error (Siesta.RequestError)
userMessage = (String) "Cannot parse server response"
httpStatusCode = (int?)nil
entity = (Siesta.Entity<Any>?)nil
When I enable the detailed logs for Siesta, it gives me the following error:
Error: RequestError(userMessage: "Cannot parse server response", httpStatusCode: nil, entity: nil, cause: Optional(Siesta.RequestError.Cause.JSONResponseIsNotDictionaryOrArray(actualType: NSTaggedPointerString)), timestamp: 562010225.337566)
Is there a way to force Siesta to accept it as a valid JSON response? If so, what steps specifically do I need to do to make that happen? I have seen other threads recommend adding an extension which has already been done, but isn't working for me.
extension String: Siesta.JSONConvertible { }