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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:29:52+00:00 2026-06-13T23:29:52+00:00

trying to call ASP.NET 4 Web API from iOS using RestKit but the serialised

  • 0

trying to call ASP.NET 4 Web API from iOS using RestKit but the serialised json object doesn’t get recognised on the server command.
Can anyone help?

obj C class;

 #import "NoddyModel.h"
 @synthesize messageId;
 @synthesize message;
 @end

(the above are NSStrings)

equiv C# from the mvc services;

using Core.MessageDocuments;

namespace WebApi.Models
{
    [DataContract]
    public class NoddysModel : List<NoddyModel>
    {
        [DataMember(IsRequired = true)]
        public long NumberOfMessages
        {
            get { return Count; }
        }   
    }

    [DataContract]
    public class NoddyModel
    {
        public NoddyModel(string MessageId, string Message)
        {
            MessageId = MessageId;
            Message = Message;
        }

        [DataMember]
        public string MessageId { get; set; }
        [DataMember]
        public string Message { get; set; }
    }
}

and the mvc command;

// POST api/Noddy
[HttpPost]
public MessagesPostResponse Post(NoddyModel noddy)
{
    int count = 999;
    try
    {
        count = noddy.Message.Length + 9000;
    }
    catch (Exception e)
    {
        FileStream traceLog = new FileStream("C:\\logs\\Traces.svclog", FileMode.Append);
        TextWriterTraceListener myListener = new TextWriterTraceListener(traceLog);
        Trace.Listeners.Add(myListener);
        myListener.WriteLine("Exception in POST NoddyModel calc count = " + e.Message + " response = " + HttpContext.Current.Request.Params.ToString());
        Trace.Flush();
        myListener.Flush();
        traceLog.Close();

        return new MessagesPostResponse(false, 0);
    }
    try
    {
        FileStream traceLog = new FileStream("C:\\logs\\Traces.svclog", FileMode.Append);
        TextWriterTraceListener myListener = new TextWriterTraceListener(traceLog);
        Trace.Listeners.Add(myListener);
        myListener.WriteLine("Sending trace information : Noddy = " + noddy);
        Trace.Flush();
        myListener.Flush();
        traceLog.Close();

        return new MessagesPostResponse(true, count);
    }
    catch (Exception e)
    {
        FileStream traceLog = new FileStream("C:\\logs\\Traces.svclog", FileMode.Append);
        TextWriterTraceListener myListener = new TextWriterTraceListener(traceLog);
        Trace.Listeners.Add(myListener);
        myListener.WriteLine("Exception in POST NoddyModel = " + e.Message);
        Trace.Flush();
        myListener.Flush();
        traceLog.Close();

        return new MessagesPostResponse(false, 0);
    }
}

and the Obj C function;

RKURL *baseURL = [RKURL URLWithString: @"http://ServerX/cirrusdev/api"];
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURLString: @"http://ServerX/cirrusdev/api"];
objectManager.client.baseURL = baseURL;
[objectManager setSerializationMIMEType:RKMIMETypeJSON];

RKObjectRouter *dynrouter = [RKObjectRouter new];
[dynrouter routeClass:[NoddyModel class] toResourcePath:@"/messages" forMethod:RKRequestMethodPOST];

objectManager.router = dynrouter;


RKObjectMapping* pmsg = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];

[pmsg mapKeyPath: @"MessageId"     toAttribute:@"messageId"    ];
[pmsg mapKeyPath: @"Message"       toAttribute:@"message"      ];

RKObjectMapping* pmsgSerializeMapping = [pmsg inverseMapping];
[objectManager.mappingProvider setSerializationMapping:pmsgSerializeMapping forClass:[NoddyModel class]];


NoddyModel *msg = [[NoddyModel alloc]init];
msg.messageId =@"abc999";
msg.message = @"Hello Cirrus";

[objectManager postObject:msg delegate:self];

and the log from RestKit;

> 2012-10-31 15:28:26.851 ELOI[74400:c07] D
> restkit.network:RKClient.m:437 Reachability to host '0.0.0.0'
> determined for client <RKClient: 0x76dda50>, unsuspending queue
> <RKRequestQueue: 0x76ddb90 name=(null) suspended=YES requestCount=1
> loadingCount=0/5> 2012-10-31 15:28:26.851 ELOI[74400:c07] D
> restkit.network:RKRequest.m:437 Sending asynchronous POST request to
> URL `http://ServerX/cirrusdev/api/messages`. 2012-10-31 15:28:26.852
> ELOI[74400:c07] D restkit.network:RKObjectLoader.m:374 POST or PUT
> request for source object <NoddyModel: 0x7696ba0>, serializing to MIME
> Type application/json for transport... 2012-10-31 15:28:26.853
> ELOI[74400:c07] T restkit.network:RKRequest.m:399 Prepared POST
> URLRequest '<NSMutableURLRequest
> http://ServerX/cirrusdev/api/messages>'. HTTP Headers: {
>     Accept = "application/json";
>     "Content-Length" = 47;
>     "Content-Type" = "application/json"; }. HTTP Body: {"MessageId":"abc999","Message":"Hello Cirrus"}. 2012-10-31
> 15:28:26.855 ELOI[74400:c07] D restkit.network:RKResponse.m:198
> Proceeding with request to <NSURLRequest
> http://ServerX/cirrusdev/api/messages> 2012-10-31 15:28:31.224
> ELOI[74400:c07] D restkit.network:RKResponse.m:219 NSHTTPURLResponse
> Status Code: 200 2012-10-31 15:28:31.224 ELOI[74400:c07] D
> restkit.network:RKResponse.m:220 Headers: {
>     "Cache-Control" = "no-cache";
>     "Content-Length" = 74;
>     "Content-Type" = "application/json; charset=utf-8";
>     Date = "Wed, 31 Oct 2012 15:28:30 GMT";
>     Expires = "-1";
>     Pragma = "no-cache";
>     Server = "Microsoft-IIS/7.5";
>     "X-AspNet-Version" = "4.0.30319";
>     "X-Powered-By" = "ASP.NET"; } 2012-10-31 15:28:31.225 ELOI[74400:c07] T restkit.network:RKResponse.m:231 Read response body:
> {"Successful":false,"Message":"We have received 0
> message(s)","Data":null}

PS I manually edited the server name so if its different please ignore

  • 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-13T23:29:53+00:00Added an answer on June 13, 2026 at 11:29 pm

    There were lots of things I needed to try by trial and error – the final thing was that the ASP.NET Web API action couldn’t instantiate the Noddy object because it needed a parameterless initializer.

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

Sidebar

Related Questions

I am trying to call a web service from asp.net 3.5 application. I have
I am trying to return an html table from a asp.net web service but
I'm trying to make a call to a JSON ASP.NET web service with .NET.
I am trying to write my first RESTful API in C# using ASP.NET Web
I'm trying to parse JSON result from an Ajax call to .NET web service
i'm trying to follow the suggestion here: Call ASP.NET function from JavaScript? But it's
I'm trying to call an ASP.NET .asmx webservice, from javascript, using other than the
I'm trying to call an asp.net webservice from the same project it's in: [MethodImpl(MethodImplOptions.Synchronized)]
I'm trying to call the MyJavascriptFunction(arg1) from an asp button and it's doesn't work...
I am trying to call ASP.net 1.1 service in asp.net using Jquery, can't figure

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.