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 8313773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:36:22+00:00 2026-06-08T20:36:22+00:00

I am successfully retrieving JSON data from a web service with GET using Restkit’s

  • 0

I am successfully retrieving JSON data from a web service with GET using Restkit’s RKObjectManager and RKObjectMapping. Here’s my code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    RKURL *baseURL = [RKURL URLWithBaseURLString:@"http://192.168.1.12"];
    RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
    objectManager.client.baseURL = baseURL;

    RKObjectMapping *markerMapping = [RKObjectMapping mappingForClass:[Marker class]];
    [markerMapping mapKeyPath:@"la" toAttribute:@"lat"];
    [markerMapping mapKeyPath:@"lo" toAttribute:@"lon"];
    [markerMapping mapKeyPath:@"des" toAttribute:@"description"];
    [objectManager.mappingProvider setMapping:markerMapping forKeyPath:@"markers"];
}

- (void)sendGet
{
    NSString *lat = @"53.334932";
    NSString *lon = @"-0.543749";
    NSString *dist = @"1000";

    NSDictionary *queryParams;
    queryParams = [NSDictionary dictionaryWithObjectsAndKeys:lat, @"la", lon, @"lo", dist, @"d", nil];
    RKObjectManager *objectManager = [RKObjectManager sharedManager];

    RKURL *URL = [RKURL URLWithBaseURL:[objectManager baseURL] resourcePath:@"/get_markers.php" queryParameters:queryParams];
    [objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"%@?%@", [URL resourcePath], [URL query]] delegate:self];
}

The above code is working and I am happily working with the returned data. However, I cannot POST a record to be inserted in the database. I think I can reuse the sharedManager and even possibly the mapping. I do not need to handle any return.

I have tried numerous variations of the following snippets. To no avail.

The first snippet is an attempt to reuse the manager and mapping. Ignoring the mapping scope in this pseudo code the obvious flaw is that I cannot work out how to POST to the correct URL resource (baseURL & ‘/insert_marker.php’). So I haven’t actually tried this:

- (void)postInsert
{  
    Marker *mkr = [Marker alloc];
    mkr.lat = @"53.334933";
    mkr.lon = @"-0.543750";
    mkr.description = @"some words";

    RKObjectManager *objectManager = [RKObjectManager sharedManager];
    [objectManager.mappingProvider setSerializationMapping:[markerMapping inverseMapping] forClass:[Marker class]];
    [[RKObjectManager objectManager] postObject:mkr delegate:nil];
}

This second snippet runs but crashes the app. Clearly, this is confused between string and url types but the object manager post will not compile with url. I am very confused!

- (void)postInsert
{  
    RKParams* params = [RKParams params];
    [params setValue:@"53.334933" forParam:@"la"];
    [params setValue:@"-0.543750" forParam:@"l0"];
    [params setValue:@"some words" forParam:@"des"];

    RKObjectManager *objectManager = [RKObjectManager sharedManager];
    NSString *URL = [RKURL URLWithBaseURL:[objectManager baseURL] resourcePath:@"/add_marker.php"];
    [objectManager.client post:URL params:params delegate:nil];
}

So, how can I POST with params (hopefully reusing the sharedManager, maybe the mapping and not handling a return)?

  • 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-08T20:36:24+00:00Added an answer on June 8, 2026 at 8:36 pm

    As posted in the comments, try using NSStrings instead of RKURL like this:

    NSString *baseUrl = @"https://mysite.com"; 
    [RKObjectManager objectManagerWithBaseURLString:baseUrl];
    

    If you want to make something more robust, you can also try to make a post using the objectManager instead the client on the objectManager, for example you can use blocks:

    - (void) post: (id) myEntity onLoad:(RKObjectLoaderDidLoadObjectBlock) loadBlock onError:(RKRequestDidFailLoadWithErrorBlock)failBlock showingLoader:(BOOL)loaderWillShow{
    
        RKObjectMapping *mapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[[myEntity class] class]];
        [[RKObjectManager sharedManager] postObject:myEntity usingBlock:^(RKObjectLoader *loader) {
            [self settingsForLoader:loader withMapping:mapping onLoad:loadBlock onError:failBlock showingLoader:loaderWillShow];
        }];
    
    }
    
    //Settings For Loader definition:
    
    
    
    - (void) settingsForLoader: (RKObjectLoader *) loader withMapping: (RKObjectMapping *) mapping onLoad:(RKObjectLoaderDidLoadObjectBlock) loadBlock onError:(RKRequestDidFailLoadWithErrorBlock)failBlock showingLoader:(BOOL) loaderWillShow{
    
        loader.objectMapping = mapping;
        loader.delegate = self;
        loader.onDidLoadObject = loadBlock;
    
        loader.onDidFailWithError = ^(NSError * error){
           //NSLog(@"%@",error);
        };
    
        loader.onDidFailLoadWithError = failBlock;
        loader.onDidLoadResponse = ^(RKResponse *response) {
            [self fireErrorBlock:failBlock onErrorInResponse:response disablingLoader:loaderWillShow];
        };
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After successfully opening Pop3Folder , and retrieving messages from it, I then sometimes get
This is user.php: include(databse.php);//retrieving successfully first name and lastname from databse file into user.php
I am retrieving the whole html and javascript of a page I get from
I'm writing an AJAX function that requests data from my JSON Python webservice. My
If I were retrieving the data I wanted from a plain sql query, the
I have created an n-tier solution where I am retrieving related data from a
After successfully acquiring an oauth_token for a user, I am able to get successful
I successfully migrate Joomla from 1.0 to 1.5.0 stable, while searching for migrate 1.5.0
I successfully compiled ActionBarSherlock in Eclipse. But I get 75 errors when I use
I successfully installed Opencv via sudo apt-get install libcv-dev libcv4 libcvaux-dev libcvaux4 libhighgui-dev libhighgui4

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.