You need to sign in to do that
Don't have an account?
Trying to insert a record on iOS SDK
Hey all,
I'm still learning how to use the SalesForce Database service and the iOS SDK. I'm trying to get it to write a record into a table called "Audits". However, my request seems to keep failing as my console reads...
5/2/12 8:43:35.152 AM CloudTest2: request:didFailLoadWithError: Error Domain=com.salesforce.RestAPI.ErrorDomain Code=999 "The operation couldn’t be completed. (com.salesforce.RestAPI.ErrorDomain error 999.)" UserInfo=0x6b5a950 {message=The requested resource does not exist, errorCode=NOT_FOUND}
I must be doing something incorrectly. Here is the method I'm using...
//Add a test record
NSString * objectType = @"Audit";
NSDictionary *fields = [@"{AuditName: Test, GroupID:1}" objectFromJSONString];
SFRestRequest *TestAdd = [[SFRestAPI sharedInstance] requestForCreateWithObjectType:objectType fields:fields];
[[SFRestAPI sharedInstance] send:TestAdd delegate:self];
What exactly am I doing wrong?
NSDictionary *dictionary=[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Test", [NSNumber numberWithInt:1], nil] forKeys:[NSArray arrayWithObjects:@"Audit", @"GroupID", nil]];
use this for the "fields" parameter when creating the request
All Answers
if the table is called Audits, why are you using Audit as the object type?
on an unrelated note, is there any reason why you are creating a dictionary out of a json string instead of using the more efficient method of initializing the NSDictionary with the proper object and keys?
Assuming Audit is a custom object, the correct name is Audit__c
I'm cloning a tutorial and I don't understand the JSON thing it's asking me to do, it's not providing context either.
Could you provide an example of a simple efficient means to insert a record?
NSDictionary *dictionary=[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Test", [NSNumber numberWithInt:1], nil] forKeys:[NSArray arrayWithObjects:@"Audit", @"GroupID", nil]];
use this for the "fields" parameter when creating the request
hi try like this
NSString * objectType = @"Audit__c";
NSDictionary *fields = [@"{AuditName: Test, GroupID:1}"
JSONValue];
SFRestRequest *TestAdd = [[SFRestAPI sharedInstance] requestForCreateWithObjectType:objectType fields:fields];
[[SFRestAPI sharedInstance] send:TestAdd delegate:self];