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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:21:11+00:00 2026-06-06T15:21:11+00:00

I have been trying to post using RestKit after I have successfully used it

  • 0

I have been trying to post using RestKit after I have successfully used it for object mapping and keep getting the error “Could not find an object mapping for keyPath: ””.

I have already had success using only JSON of iOS with the following code:

responseData = [NSMutableData data];

NSURL *url = [NSURL URLWithString:@"http://lalubema.cloudapp.net:9000/Data.soap/Pessoa"];

NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:@"Objective-c test from send Request #1" forKey:@"Nome"];
[params setObject:@"/Date(1200355200000)/" forKey:@"DataNascimento"];   
[params setObject:@"M" forKey:@"Sexo"];
[params setObject:@"(31)2321-2383" forKey:@"Telefone"];

NSError *jsonError;
NSData *requestdata = [NSJSONSerialization dataWithJSONObject:params options:0 error:&jsonError];

NSMutableURLRequest *request;
request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"%d", [requestdata length]] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:requestdata];

//this kicks off the request asynchronously
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

The code I am trying with RestKit and getting the error is the following:

[RKObjectManager sharedManager].serializationMIMEType = RKMIMETypeJSON;
[RKObjectManager sharedManager].acceptMIMEType = RKMIMETypeJSON;

RKObjectMapping* pessoaMapping = [RKObjectMapping mappingForClass:[Pessoa class]];
pessoaMapping.setDefaultValueForMissingAttributes = YES;
[pessoaMapping mapKeyPath:@"DataNascimento" toAttribute:@"dataNascimento"];
[pessoaMapping mapKeyPath:@"Nome" toAttribute:@"nome"];
[pessoaMapping mapKeyPath:@"Sexo" toAttribute:@"sexo"];
[pessoaMapping mapKeyPath:@"Telefone" toAttribute:@"telefone"];
[[RKObjectManager sharedManager].mappingProvider addObjectMapping:pessoaMapping]; 

RKObjectMapping* pessoaSerializationMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
[pessoaSerializationMapping mapAttributes:@"dataNascimento", @"docIdentidade", @"email", @"foto", @"pid", @"nome", @"senha", @"sexo", @"telefone", nil];    
[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:pessoaSerializationMapping forClass:[Pessoa class]];

RKObjectRouter *router = [[RKObjectManager sharedManager] router];

[router routeClass:[Pessoa class] toResourcePath:@"/Pessoa/:id"];
[router routeClass:[Pessoa class] toResourcePath:@"/Pessoa" forMethod:RKRequestMethodPOST];

Pessoa *Novo = [[Pessoa alloc] init];

Novo.nome = @"Objective-c test from send postPessoa #1";
Novo.telefone = @"(31)1234-5678";
Novo.sexo = @"M";

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd-MM-yyyy"];    

RKDotNetDateFormatter *dotNetFormattedDate = [[RKDotNetDateFormatter alloc] init];
NSString *data = [dotNetFormattedDate stringFromDate:[df dateFromString: @"10-10-1979"]];

Novo.dataNascimento = data;

// POST to /Pessoa
[[RKObjectManager sharedManager] postObject:Novo delegate:self];

The RKLog error is:

2012-06-27 17:58:28.539 MyTestApp[6101:fb03] I restkit:RKLog.m:33 RestKit initialized…

2012-06-27 17:58:28.589 MyTestApp[6101:fb03] I restkit.network.reachability:RKReachabilityObserver.m:369 Network availability has been determined for reachability observer

2012-06-27 17:58:41.260 MyTestApp[6101:fb03] W restkit.object_mapping:RKObjectMapper.m:81 Adding mapping error: Could not find an object mapping for keyPath: ”

2012-06-27 17:58:41.261 MyTestApp[6101:fb03] E restkit.network:RKObjectLoader.m:222 Encountered errors during mapping: Could not find an object mapping for keyPath: ”

2012-06-27 17:58:41.261 MyTestApp[6101:fb03] E restkit.network:RKObjectLoader.m:345 Encountered an error while attempting to map server side errors from payload: Could not find an object mapping for keyPath: ”

2012-06-27 17:58:41.262 MyTestApp[6101:fb03] Erro encontrado: Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 “Could not find an object mapping for keyPath: ”” UserInfo=0x808fac0 {=RKObjectMapperKeyPath, NSLocalizedDescription=Could not find an object mapping for keyPath: ”}

  • 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-06T15:21:13+00:00Added an answer on June 6, 2026 at 3:21 pm

    I think the main problem is represented by this code block:

    RKObjectMapping* pessoaMapping = [RKObjectMapping mappingForClass:[Pessoa class]];
    pessoaMapping.setDefaultValueForMissingAttributes = YES;
    [pessoaMapping mapKeyPath:@"DataNascimento" toAttribute:@"dataNascimento"];
    [pessoaMapping mapKeyPath:@"Nome" toAttribute:@"nome"];
    [pessoaMapping mapKeyPath:@"Sexo" toAttribute:@"sexo"];
    [pessoaMapping mapKeyPath:@"Telefone" toAttribute:@"telefone"];
    [[RKObjectManager sharedManager].mappingProvider addObjectMapping:pessoaMapping]; 
    
    RKObjectMapping* pessoaSerializationMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
    [pessoaSerializationMapping mapAttributes:@"dataNascimento", @"docIdentidade", @"email", @"foto", @"pid", @"nome", @"senha", @"sexo", @"telefone", nil];    
    [[RKObjectManager sharedManager].mappingProvider setSerializationMapping:pessoaSerializationMapping forClass:[Pessoa class]];
    

    that you should try replacing with:

    RKObjectMapping* pessoaMapping = [RKObjectMapping mappingForClass:[Pessoa class]];
    pessoaMapping.setDefaultValueForMissingAttributes = YES;
    [pessoaMapping mapKeyPath:@"DataNascimento" toAttribute:@"dataNascimento"];
    [pessoaMapping mapKeyPath:@"Nome" toAttribute:@"nome"];
    [pessoaMapping mapKeyPath:@"Sexo" toAttribute:@"sexo"];
    [pessoaMapping mapKeyPath:@"Telefone" toAttribute:@"telefone"];
    // up until this point, the code is the same, changes below
    // -------------------------------------------------------------------------------
    // map rest of the attributes, considering key paths match attribute names exactly
    [pessoaMapping mapAttributes:@"docIdentidade", @"email", @"foto", @"pid", @"senha", nil];
    // set the serialization mapping
    [[RKObjectManager sharedManager].mappingProvider setSerializationMapping:[pessoaMapping inverseMapping] forClass:[Pessoa class]];
    

    Also, another problem is at the following line:

    [router routeClass:[Pessoa class] toResourcePath:@"/Pessoa/:id"];
    

    The identifier attribute in your Pessoa class seems to be named pid, as seen in the mapAttributes: call. When setting the resource path to the router, I presume RestKit does not know what to replace the value of :id with, using KVC.

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

Sidebar

Related Questions

I have been trying to post login credentials to an https site using cURL
I have been trying to post some variables to a site using POST method,
I have been trying to write a bare-bones ping scanner using Perl for internal
Using MVC 2 I have been trying to make this record store project. Creating
I'm trying to POST a serialized object to my WCF service. However, I keep
I am using tablesorter 2.0 and I have been trying to override the css
I have been trying to use one View for updating an object and all
I have been trying to display json data in my jsp using struts and
I have been trying to write a script where I can post data to
I have been trying to do a query using Microsoft SQL Server 2008 R2,

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.