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

  • Home
  • SEARCH
  • 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 9120375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:36:50+00:00 2026-06-17T05:36:50+00:00

When I use the postObject method in RestKit, everything seems okay by the log

  • 0

When I use the postObject method in RestKit, everything seems okay by the log (see below).

But on the server, the request is received as GET and the request body is empty, instead of being a POST and containing the serialized object.

2013-01-12 14:40:08.860 AppName[3953:c07] I restkit.network:RKHTTPRequestOperation.m:152 POST 'http://urlgoeshere.com'

Below is the code I am using for the POST and the RestKit initialization. I am using RestKit 0.20.0-pre6.

POST Object to Server

// CREATE THE MANAGED OBJECT, AND SAVE IT
RKManagedObjectStore *objectStore = [[RKObjectManager sharedManager] managedObjectStore];
Message *msg = [NSEntityDescription insertNewObjectForEntityForName:@"Message" inManagedObjectContext:objectStore.mainQueueManagedObjectContext];
msg.note = @"This is a sample message.";
msg.dateCreated = [NSDate date];
[objectStore.mainQueueManagedObjectContext save:nil];

// BUILD THE REQUEST MAPPING & REQUEST DESCRIPTOR
RKObjectMapping *requestMapping = [RKObjectMapping requestMapping];
[requestMapping addAttributeMappingsFromDictionary:@{
 @"messageId": @"id",
 @"dateCreated": @"date_created",
 }];
[requestMapping addAttributeMappingsFromArray:@[ @"note" ]];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:requestMapping objectClass:[Message class] rootKeyPath:@"message"];
[[RKObjectManager sharedManager] addRequestDescriptor:requestDescriptor];

// SEND POST REQUEST TO SERVER
[[RKObjectManager sharedManager] postObject:msg
                                       path:@"/path/to/messages"
                                 parameters:[NSDictionary dictionaryWithObject:[(AppDelegate*)[[UIApplication sharedApplication] delegate] userId] forKey:@"user_id"]
                                    success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                                        NSLog(@"success!");
                                    }
                                    failure:^(RKObjectRequestOperation *operation, NSError *error) {
                                        NSLog(@"failure.\n\n%@", [error description]);
                                    }
 ];

RestKit Initialization in App Delegate

NSURL *baseURL = [NSURL URLWithString:@"http://urlgoeshere.com"];
RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:baseURL];

// Initialize managed object store
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
objectManager.managedObjectStore = managedObjectStore;

// Setup our object mappings    
RKEntityMapping *messageMapping = [RKEntityMapping mappingForEntityForName:@"Message" inManagedObjectStore:managedObjectStore];
messageMapping.identificationAttributes = @[ @"messageId" ];
[messageMapping addAttributeMappingsFromDictionary:@{
 @"id": @"messageId",
 @"date_created": @"dateCreated",
 }];
[messageMapping addAttributeMappingsFromArray:@[ @"note" ]];

[managedObjectStore createPersistentStoreCoordinator];
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"DBNameHere.sqlite"];
NSError *error;
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:&error];
NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error);

// Create the managed object contexts
[managedObjectStore createManagedObjectContexts];

// Configure a managed object cache to ensure we do not create duplicate objects
managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext];
  • 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-17T05:36:51+00:00Added an answer on June 17, 2026 at 5:36 am

    What kind of server are you talking to? I would suspect that your server is doing a redirect or something. RestKit uses NSURLConnection to make the requests, so its extremely unlikely that the issue is client side as what you see reported in the logs is read directly from the NSURLRequest.

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

Sidebar

Related Questions

Yes, I know it is best to use webmock, but I would like to
I was using this method to POST my objects, but it's been deprecated: -
I'm trying to use a variable as a command's parameter but can't quite figure
I am using RestKit to drive interactions with my web server. I am trying
Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt
use ThreadPool.QueueUserWorkItem (WaitCallback, Object) to start a thread with my target method and data.
When adding a method to a PSObject using Add-Member is it possible to use
I have such method: <T extends Entity> boolean putObject(T value); But can`t find out
use Mojolicious::Lite; # /with_layout get '/a' => sub { my $self = shift;} ;
I am using RestKit framework and i want to make a POST HTTP request.

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.