         guard let content = try? body.serialize() else {
             let failureReason = "Content items could not be serialized to JSON."
             let userInfo = [NSLocalizedFailureReasonErrorKey: failureReason]
-            let error = NSError(domain: PersonalityInsights.domain, code: 0, userInfo: userInfo)
+            let error = NSError(domain: domain, code: 0, userInfo: userInfo)
             failure?(error)
             return
         }

        guard let content = html.dataUsingEncoding(NSUTF8StringEncoding) else {
            let failureReason = "HTML could not be encoded to NSData with NSUTF8StringEncoding."
            let userInfo = [NSLocalizedFailureReasonErrorKey: failureReason]
            let error = NSError(domain: PersonalityInsights.domain, code: 0, userInfo: userInfo)
            failure?(error)
            return
        }

        // construct REST request
        let request = RestRequest(
            method: .POST,
            url: serviceURL + "/profile",
            acceptType: "application/json",
            contentType: contentType,
            queryParameters: queryParameters,
