Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:43:56+00:00 2026-06-18T07:43:56+00:00

I am having a problem posting an NSManagedObject using RestKit 0.20pre6 where it results

  • 0

I am having a problem posting an NSManagedObject using RestKit 0.20pre6 where it results in creating an entry on my Rails site with nil values. I suspect the mapper but I have set up my RK objects to the best of my knowledge correctly. There are very few examples and limited support. The example deals with NSObjects and not CoreData so I’ve had to make some assumptions.

Here is my code for posting and followed by the console output. The app gets objects from the server fine.

        // Sync the added object to the server
    // ****************************************

    RKObjecMapping *responseMapping = [RKObjectMapping mappingForClass:[Event class]];
//  RKEntityMapping *responseMapping = [RKEntityMapping mappingForEntityForName:@"Event" inManagedObjectStore:self.managedObjectStore];
    [responseMapping addAttributeMappingsFromDictionary:@{
     @"id": @"eventId",
     @"name": @"name",
     @"amount": @"amount",
     @"length": @"length",
     @"updated_at": @"updatedAt",
     @"created_at": @"createdAt",
     @"latitude": @"latitude",
     @"longitude": @"longitude",
     @"thumbnail": @"thumbnail",
     @"airTemp": @"airTemp",
     }];

    NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful); // Anything in 2xx
    RKResponseDescriptor *eventDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:responseMapping
                                                                                    pathPattern:@"/events"
                                                                                        keyPath:@"events"
                                                                                    statusCodes:statusCodes
                                                                                                ];

    RKObjectMapping *requestMapping = [RKObjectMapping requestMapping]; // objectClass == NSMutableDictionary

    [requestMapping addAttributeMappingsFromDictionary:@{
     @"id": @"eventId",
     @"name": @"name",
     @"amount": @"amount",
     @"length": @"length",
     @"updated_at": @"updatedAt",
     @"created_at": @"createdAt",
     @"latitude": @"latitude",
     @"longitude": @"longitude",
     @"thumbnail": @"thumbnail",
     @"airTemp": @"airTemp",
     }];


    // For any object of class Article, serialize into an NSMutableDictionary using the given mapping and nest
    // under the 'article' key path
    RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:requestMapping
                                                                                   objectClass:[Event class]
                                                                                   rootKeyPath:@"events"
                                                                                                ];

    LocationsAppDelegate *appDelegate = (LocationsAppDelegate *)[[UIApplication sharedApplication] delegate];
//  RKObjectManager *manager = [RKObjectManager managerWithBaseURL:gBaseURL];


    [RKObjectManager sharedManager].requestSerializationMIMEType = RKMIMETypeJSON;
    [[RKObjectManager sharedManager] addRequestDescriptor:requestDescriptor];
    [[RKObjectManager sharedManager] addResponseDescriptor:eventDescriptor];

    NSLog(@"RVC-addEvent %@ - %@", appDelegate.user.login, appDelegate.user.password);
    [[NBEventManager sharedManager] setUsername:appDelegate.user.login andPassword:appDelegate.user.password];
    appDelegate.objectManager.HTTPClient = [NBEventManager sharedManager];


    event = [eventsArray objectAtIndex:0];
    [[RKObjectManager sharedManager] postObject:event
                                           path:@"/events"
                                     parameters:nil
                                        success:nil
                                        failure:nil
                                                ];

}

2013-01-15 23:25:52.857 fish[38803:13403] I
restkit.network:RKHTTPRequestOperation.m:152 POST
‘http://localhost:3000/events’ 2013-01-15 23:25:52.969
fish[38803:16903] I restkit.network:RKHTTPRequestOperation.m:179 POST
‘http://localhost:3000/events’ (201 Created) [0.1121 s] 2013-01-15
23:25:52.971 fish[38803:17507] D
restkit.object_mapping:RKMapperOperation.m:360 Executing mapping
operation for representation: {
event = {
airTemp = “”;
amount = “”;
“created_at” = “2013-01-16T04:25:52Z”;
id = 54;
latitude = “”;
length = “”;
longitude = “”;
name = “”;
thumbnail = “”;
“updated_at” = “2013-01-16T04:25:52Z”;
“user_id” = “”;
}; } and targetObject: (entity: Event; id: 0x9c7f710
; data:
{
airTemp = 0;
amount = nil;
createdAt = “2013-01-16 04:25:52 +0000”;
eventId = 0;
latitude = “28.158466”;
length = 0;
longitude = “-82.509215”;
name = nil;
photo = nil;
thumbnail = nil;
updatedAt = nil; }) 2013-01-15 23:25:52.971 fish[38803:17507] D restkit.object_mapping:RKMapperOperation.m:287 Found mappable data at
keyPath ‘event’: {
airTemp = “”;
amount = “”;
“created_at” = “2013-01-16T04:25:52Z”;
id = 54;
latitude = “”;
length = “”;
longitude = “”;
name = “”;
thumbnail = “”;
“updated_at” = “2013-01-16T04:25:52Z”;
“user_id” = “”; } 2013-01-15 23:25:52.971 fish[38803:17507] D restkit.object_mapping:RKMapperOperation.m:232 Asked to map source
object {
airTemp = “”;
amount = “”;
“created_at” = “2013-01-16T04:25:52Z”;
id = 54;
latitude = “”;
length = “”;
longitude = “”;
name = “”;
thumbnail = “”;
“updated_at” = “2013-01-16T04:25:52Z”;
“user_id” = “”; } with mapping eventId>”,
” name>”,
” amount>”,
” length>”,
” updatedAt>”,
” createdAt>”,
” latitude>”,
” longitude>”,
” airTemp>”,
” thumbnail>” )> 2013-01-15 23:25:52.971 fish[38803:17507] D
restkit.object_mapping:RKMappingOperation.m:754 Starting mapping
operation… 2013-01-15 23:25:52.972 fish[38803:17507] D
restkit.object_mapping:RKMappingOperation.m:818 Finished mapping
operation successfully… 2013-01-15 23:25:52.973 fish[38803:17507] D
restkit.object_mapping:RKMapperOperation.m:316 Found unmappable value
at keyPath: events 2013-01-15 23:25:52.973 fish[38803:17507] D
restkit.object_mapping:RKMapperOperation.m:389 Finished performing
object mapping. Results: {
event = ” (entity: Event; id: 0x9c7f710
; data:
{\n airTemp = nil;\n amount = nil;\n createdAt = \”2013-01-16
04:25:52 +0000\”;\n eventId = 54;\n latitude = nil;\n length
= nil;\n longitude = nil;\n name = nil;\n photo = nil;\n thumbnail = nil;\n updatedAt = \”2013-01-16 04:25:52 +0000\”;\n})”;
} 2013-01-15 23:25:52.973 fish[38803:13403] D
restkit.core_data:RKManagedObjectRequestOperation.m:534 Skipping
deletion of orphaned objects: only performed for GET requests.
2013-01-15 23:25:52.976 fish[38803:11f03] D
restkit.core_data:RKManagedObjectRequestOperation.m:599 Refreshing
mapped target object (entity: Event; id:
0x9c7f710
; data:
{
airTemp = nil;
amount = nil;
createdAt = “2013-01-16 04:25:52 +0000”;
eventId = 54;
latitude = nil;
length = nil;
longitude = nil;
name = nil;
photo = nil;
thumbnail = nil;
updatedAt = “2013-01-16 04:25:52 +0000”; }) in context

Here is my code now as I have moved all of the mappings to the app delegate and have implemented RKEntityMapping. I still get no JSON object attached to the POST call.

    RKEntityMapping *eventMapping = [RKEntityMapping mappingForEntityForName:@"Event" inManagedObjectStore:managedObjectStore];
[eventMapping addAttributeMappingsFromDictionary:@{
 @"id": @"eventId",
 @"name": @"name",
 @"amount": @"amount",
 @"length": @"length",
 @"updated_at": @"updatedAt",
 @"created_at": @"createdAt",
 @"latitude": @"latitude",
 @"longitude": @"longitude",
 @"thumbnail": @"thumbnail",
 @"airTemp": @"airTemp",
 }];
eventMapping.identificationAttributes = @[ @"eventId" ];

//RKRelationshipMapping *eventRelationship = [RKRelationshipMapping relationshipMappingFromKeyPath:@"events"
//                                                                                     toKeyPath:@"events"
//                                                                                   withMapping:eventMapping];
//[eventMapping addPropertyMapping:eventRelationship];

// Register our mappings with the provider
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:eventMapping
                                                                                   pathPattern:nil
                                                                                       keyPath:@"event"
                                                                                   statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:responseDescriptor];

RKEntityMapping *eventRequestMapping = [eventMapping inverseMapping];
RKRequestDescriptor *eventRequestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:eventRequestMapping
                                                                                    objectClass:[Event class]
                                                                                    rootKeyPath:@"event"
                                                                                                ];
[objectManager addRequestDescriptor:eventRequestDescriptor];
[RKObjectManager sharedManager].requestSerializationMIMEType = RKMIMETypeJSON;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:43:57+00:00Added an answer on June 18, 2026 at 7:43 am

    After getting a better understanding of managedObjectContexts and how RestKit utilizes two of them in particular I was able to get into the right context. There are two created with the createContexts a mainQueue and a persistentStore Context. Also of not is that I needed to select my Event Entity in the data model and change the class from NSManagedObject to Event and RestKit then recognized the entity as that of class Event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with using Google Checkout and am having a problem posting to the
I'm having a problem with Rails not POSTing anything in the params to an
I'm having problem posting a share to LinkedIn from my Android application. I'm using
I'm having a weird problem with Restkit+iOS 5 + Rails: when I attempt to
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
Hi I seem to be having a problem when posting images.I have checked many
I'm having this problem on posting a page. The page have a jquery ajax
`Greetings, Having problem posting multiple parameters to an mc controller method. controller... [HttpPost] public
i am having a Problem posting a Picture in the Wall of an Event
I am having a small problem on posting some text from a textarea as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.