I having some trouble accessing the REST API from Domino Access Service (9.0.1) via Alamofire in swift. My code looks like:
Alamofire.request(.GET, dbPath)
.authenticate(usingCredential: credential)
.responseViewCollectionArray { (request, response, viewWrapper, error) in
println("res: \(response)")
if let anError = error {
println("error \(anError)")
completionHandler(nil, anError)
return
}
println("success atPath")
completionHandler(viewWrapper, nil)
}
What brings me as result:
res: Optional( { URL: http://das.name.de/DASLib.nsf/api/data/collections } { status code: 404, headers { "Cache-Control" = "no-cache"; Connection = close; "Content-Length" = 220; "Content-Type" = "text/html; charset=US-ASCII"; Date = "Mon, 06 Apr 2015 06:41:37 GMT"; Expires = "Tue, 01 Jan 1980 06:00:00 GMT"; Server = "Lotus-Domino"; } }) 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=0x7fc911f01af0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
So the content-type is wrong why I got an error when putting it into a JSON (swiftyJSON). I can see the "wrong" result using responseString instead of responseJSON from Alamofire. The strange part now is. When I am putting the end point in a rest client like CocoaRestClient it gives me a different content-type
HTTP 200 No Error
Content-Encoding: gzip Content-Length: 489 Vary: Accept-Encoding Content-Type: application/json Server: Lotus-Domino Date: Sun, 05 Apr 2015 19:41:28 GMT
If I am accessing a different part off the Domino-REST-API (e.g. the Databases on the Server) with the same code (only changing the end point). The code works well and I got the JSON.
So what am I missing? Maybe someone had the same problem when using REST via xPages in Domino.
text/html
content type) instead of the JSON feed. – Mark Leusink