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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:43:11+00:00 2026-06-15T01:43:11+00:00

I have a simple client that sends data to the web api server through

  • 0

I have a simple client that sends data to the web api server through a generic type

The following structure exists on both server and client

public interface IRequest<T>
{
    string ApiKey { get; set; }
    T RequestObject { get; set; }
}

public class UserRequest : IRequest<UserDetail>
{
    public string ApiKey { get; set; }
    public UserDetail RequestObject { get; set; }
}

I send a request to the server using the following syntax

var client = new RestClient(WebConfigurationManager.AppSettings["apiUri"]);
var profileRequest = new UserRequest
            {
                ApiKey = "xxxxx",
                RequestObject = new UserDetail {Password = txtPassword.Text, UserName = txtUserName.Text}
            };
 var request = new RestRequest("UserRequest/PostUserDetail", Method.POST);
 request.AddObject(profileRequest);

Now the interesting thing is that on the Server side, the UserDetail object does not get de-serialised properly, it just contains NULL, the ApiKey property is set correctly though

 public UserDetail PostUserDetail(UserRequest userRequest)
    {
        return new UserDetail { Password = userRequest.RequestObject.Password, UserName = userRequest.RequestObject.UserName };
    }

from the above, userRequest.ApiKey is set, however, userRequest.RequestObject is always NULL on the server API

Are generic types not supported? if not, does anyone have any pointers as to how I could modify the Deserializer on the server side? I have checked to see if the object is constructed properly on the client side and it is.

Many Thanks

  • 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-15T01:43:12+00:00Added an answer on June 15, 2026 at 1:43 am

    This Web Api scenario is supported. I have tried repro’ing your WebAPI by creating a UserRequest ApiController with PostUserDetail, and I was able to get the expected ‘Password’ and ‘UserName’ in the response:

    Request Content:
    {"ApiKey":"123","RequestObject":{"Password":"bar","UserName":"foo"}}
    
    Response Content:
    {"Password":"bar","UserName":"foo"}
    

    On the client side, I would recommend you to use HttpClient instead. Here is my client repro:

            var httpClient = new HttpClient();
            var content = new ObjectContent<UserRequest>(profileRequest, new JsonMediaTypeFormatter());
            var response2 = httpClient.PostAsync(addr, content).Result; // using .Result here for simplicity...
            Console.WriteLine(response2.Content.ReadAsStringAsync().Result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a desktop client that sends data to a web server and I
I have a simple ChatClient that sends data to a Server. In order for
In a Max/MSP module I have a simple Tcp client that sends data to
I have a huge Web App that's switching from a HTML-rendered-on-the-server-and-pushed-to-the-client approach to a
I have created a simple chat server that is driven by client polling. Clients
I have a client that connects to server, starts sending binary data and when
I have two simple programs set up that share data through a unix domain
For a client I have build a simple script that uploads multiple files(images), resizes
I have a simple client-server app on android. the android service communicates with the
I have a simple client/server setup. The server is in C and the client

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.