         callNS(json, endpoint: endpoint, method: "POST") { (result) in
             switch result {
             case .success(let json):
-                guard let insertedEntries = json as? [[String: Any]] else {
-                    completion(.failure(UploadError.invalidResponse(reason: "Expected array of objects in JSON response")))
+                guard let insertedEntries = json as? [[String: Any]], insertedEntries.count == json.count else {
+                    completion(.failure(UploadError.invalidResponse(reason: "Expected array of \(json.count) objects in JSON response")))
                     return
                 }
 


    /// Attempts to modify nightscout treatments. This method will not retry if the network task failed.
    ///
    /// - parameter treatments:        An array of nightscout treatments. The id attribute must be set, identifying the treatment to update.
    /// - parameter completionHandler: A closure to execute when the task completes. It has a single argument for any error that might have occurred during the modify.
    public func modifyTreatments(_ treatments:[NightscoutTreatment], completionHandler: @escaping (Error?) -> Void) {
        dataAccessQueue.async {

                        completion(.failure(error))
                        return
                    }
                    
                    guard let data = data, !data.isEmpty else {
                        completion(.success([]))
                        return
                    }

