Swift - iOS - Server Error Fault 1009 - Persistence Service

Hi,
I have my backendless tables populated with data and I am trying to load objects from backendless, but I receiving the following error:
Server reported an error: FAULT = ‘1009’ [Unable to retrieve data - unknown entity] <unable to="" retrieve="" data="" -="" unknown="" entity="">
Can someone please help?
This is my first Swift app for iOS and first time using Backendless. Any suggestions appreciated!
This is is what I have:

override func viewDidLoad() {


 super.viewDidLoad()
 var startTime = NSDate()
// tableView.delegate = self
// tableView.dataSource = self
 backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
 
 backendless.persistenceService.of(coffee_details.ofClass()).find(
 BackendlessDataQuery(), response: { (results: BackendlessCollection!) -> () in
 var currentPage = results.getCurrentPage()
 
 //println("Loaded \(currentPage.count) results objects")
 println("Total results in the Backendless storage - \(results.totalObjects)")
 
 for result in currentPage {
 println("Results = \(result.name)")
 }
 
 println("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")
 }
 ,
 
 error: { (var fault : Fault!) -> () in
 println("Server reported an error: \(fault)")
 })
 
 }
 override func didReceiveMemoryWarning() {
 super.didReceiveMemoryWarning()
 // Dispose of any resources that can be recreated.
 }

Hi Corbin!

Server sends this error message when you try to get access to non existing entity in data service.
Please re-check name of data table which you use.

Regards,
Kate.

Hi Kate!

Yes, I have tried double checking the syntax of my backendless data table and the tables are populated with records. The only response I am able to get is when change my object to Users. It’s not seeing the other tables I created.

I am following this tutorial:
https://backendless.com/feature-16-data-retrieval-api-how-to-load-objects-from-an-mbaas-storage/

I get a Nil response when use the Users table:
backendless.persistenceService.of(Users.ofClass()).find(

Could it be my object setup?

Any help is appreciated, thanks!

Hi Corbin,

Please see the example in this article which describes how to retrieve application’s user objects: https://backendless.com/feature-52-fetching-applications-user-objects/

Were you able to get the objects from the coffee_details table?

Regards,
Mark

Hi Mark,

Thanks for the article link. I am not trying to load user objects at the moment, but I will reference that tutorial in the future.

I am still not able to get any objects from my coffee_details table or any of the other tables I have populated. I only get a response when I use the Users (for testing purposes), other tables are returning that same fault error :frowning:

Hi Corbin,

Could you please paste the code for the coffee_details class? Also, please attach a screenshot of the coffee_details schema (Data screen > select the table > click the Schema and Permissions button).

Regards,
Mark

coffee_details.swift:









import Foundation




class coffee_details: BackendlessEntity {

    var name : String?

    var objectID : String?

    //var telephone : String?

    var address : String?

    var hours : String?

}

Thanks Mark!

Thanks, Corbin. Could you please try the following changes:

    Extend coffee_details from NSObject rather than BackendlessEntity Change objectID to objectId (lower case "d")
Please let us know if it makes any difference.

Regards,
Mark

  1. Made the change.

  2. Made the change.

I am still receiving FAULT 1009.

Here’s what I have in my Search.swift view controller:









import UIKit




class Search: UIViewController, UITableViewDelegate {

    //UITableViewDataSource ADD ^

    var backendless = Backendless.sharedInstance()




    @IBOutlet weak var tableView: UITableView!

    

    var results: [NSDictionary]!

    

    

    override func viewDidLoad() {

        super.viewDidLoad()

        var startTime = NSDate()

//        tableView.delegate = self

//        tableView.dataSource = self

        backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)

        

        backendless.persistenceService.of(coffee_details.ofClass()).find(

            BackendlessDataQuery(), response: { (results: BackendlessCollection!) -> () in

                var currentPage = results.getCurrentPage()

                

                //println("Loaded \(currentPage.count) results objects")

                println("Total results in the Backendless storage - \(results.totalObjects)")

                

                for result in currentPage {

                    println("Results = \(result.name)")

                }

                

                println("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")

            }

            ,

            

            error: { (var fault : Fault!) -> () in

                println("Server reported an error: \(fault)")

        })

        

    }




    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

Thanks!

Hi Corbin!
I tried your sample and on my side it works without errors:
https://monosnap.com/file/cKD8Z0Uq8vpNnJsLKOFYSmmpa3TWc5
Could you check if you use correct appid and secret key?
Also will be great if you provide your appid and we will check this issue with your Backendless app.
Regards,
Kate.

Hi Kate,

Thank you for the suggestion. I didn’t know I needed to declare the two keys and version number again inside ViewDidLoad. I only put the keys and version inside the AppDelegate.swift file as constants. Let me try that later this evening once I get home. Hopefully that works!

Feel free to check my issue, here is my AppID:

AA9D0225-3DF1-DC0F-FF91-2B1E67968100

Thank you!

Hi Kate & Mark,

Quick update, I was able to get responses from my data table! Thank you so much for all the help! The problem was the iOS secret key! I have another Backendless account and I got confused between the two. My fault I did not think to check the keys. I created the other account before my team mate told me he created one already with data tables populated. Rookie mistake haha.

Thanks again!

  • Corbin