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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:27:51+00:00 2026-06-12T15:27:51+00:00

I can call my service using /api/X path via Javascript. (POST verb) I can

  • 0

I can call my service using “/api/X” path via Javascript. (POST verb)

I can call same service without request object using client.Get(serviceUrl) //client is JsonServiceClient

But client.Send(X) does not work. I’m getting weird 404 NotFound response?

Am I missing something? And how can I debug problem?

The cost is 5 hours till now!

CheckList

  • X class have two string property (No enum or customType)
  • X and XResponse has DataContract and DataMember attributes (Trial)

Code:

In AppHost.cs

    base.SetConfig(new EndpointHostConfig
        {
            GlobalResponseHeaders =
                {
                    { "Access-Control-Allow-Origin", "*" },
                    { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                },
            AppendUtf8CharsetOnContentTypes = new HashSet<string> { ContentType.Html },
            DebugMode = true, //Show StackTraces in service responses during development
            LogFactory = new ElmahLogFactory(new Log4NetFactory())
        });

        //Set JSON web services to return idiomatic JSON camelCase properties
        ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

        //Configure User Defined REST Paths
        Routes.Add<JobRequest>("/job");

In Model.cs

  [DataContract]
public class JobRequest : IReturn<JobRequestResponse>
{
    [DataMember]
    public string JobRequestEnum { get; set; }
    [DataMember]
    public string JobData { get; set; }
}

[DataContract]
public class JobRequestResponse : IHasResponseStatus
{
    [DataMember]
    public string Message { get; set; }

    [DataMember]
    public ResponseStatus ResponseStatus { get; set; }
}

In JobService.cs

 public class JobService : ServiceStack.ServiceInterface.Service
{
    public JobRepository Repository { get; set; }

    public object Any(JobRequest request)
    {
        return new JobRequestResponse() { Message = "ok" };
    }
}

In Javascript.js // IT WORKS

$.ajax({
type: 'POST',
url: "/api/job",
data: '{ "jobRequestEnum": "test", "jobData": "test" }',
dataType: "json",
contentType: "application/json",
success: function (res) {
    debugger;
}

});

In CallJob.js // IT DOES NOT WORK

string serviceUrl = ConfigurationManager.AppSettings["serviceUrl"];

        using (JsonServiceClient client = new JsonServiceClient(serviceUrl))
        {
            var request = new JobRequest() { JobData = "test", JobRequestEnum = "test" };
            var response = client.Send<JobRequestResponse>(request);
        }
  • 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-12T15:27:52+00:00Added an answer on June 12, 2026 at 3:27 pm

    If you add the [Route] on your Request DTO like:

    [Route("/job")]
    [DataContract]
    public class JobRequest : IReturn<JobRequestResponse>
    {
        [DataMember]
        public string JobRequestEnum { get; set; }
        [DataMember]
        public string JobData { get; set; }
    }
    

    The new IReturn C# Client APIs

    Then the C# Client will be able to use the custom /job route on the client, e.g:

    var client = new JsonServiceClient(serviceUrl);
    var request = new JobRequest { JobData = "test", JobRequestEnum = "test" };
    JobRequestResponse response = client.Post(request);
    

    Whenever you don’t have the Route defined on the Request DTO or specify the Response type, e.g:

    var response = client.Send<JobRequestResponse>(request);
    

    You’re not using the IReturn<T> C# client API so it will send a POST to the pre-defined route which for this would be:

    POST /json/syncreply/JobsRequest
    { ... }
    

    Not /jobs as you’re assuming (i.e. the C# client has no way to know of the route info, so it falls back to using the pre-defined routes).

    Manually specifying to use the /customroute

    Otherwise if you want to keep your Route definitions in AppHost you can force it to use the pre-defined url by supplying it in the C# call, e.g:

    client.Post<JobRequestResponse>("/job", request);
    

    No need for ‘Response’ suffix

    Also in the new API (and when you use the IReturn<T> marker) you no longer need the Request DTO + ‘Response’ naming convention and are free to choose any name you need, so it doesn’t have to be JobRequestResponse which sounds a little awkward 🙂

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

Sidebar

Related Questions

I am using curl to call a web service API. The service can unresponsive
I'm trying to call a WCF service using soap in IE8 and I can't
Since you can call the the Soundcloud API via XHR (because of the CORS
When using the SIP API, how can I answer a call I'm receiving. Im
I'm trying to make my first web service client for the eBay API using
I am looking for a VoIP service my application can use to call landlines
Using a delegate I can call any function asynchronously. From the documentation I understand
I'm using the Jersey Client library to run tests against a rest service running
I'm using the Windows HTTP API to process web service requests in C++ (not
I'm using a Web Service that has a endpoint of http://api.domain_a.com/ and using Visual

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.