troubleshooting Question

No HTTP resource was found that matches the request URI

Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America asked on
C#HTTP ProtocolTroubleshooting
4 Comments1 Solution253 ViewsLast Modified:
I need help troubleshooting / fixing the problem:

The request in POSTMAN:
POST /sforce/createworkorder HTTP/1.1
Host: localhost:29081
Authorization: Bearer vvThd_mOentifQX YOU GET THE IDEA eMARduXY2E2uJ_pw2QDYumZ7YdKIyYSpeMvPBIFEMMi-P3jhKWthLATNcdX5HuDqyUdq30QYiPbJgRLkoYHjB4NhuT8UoAsagoRcToDTSQuIouWred1cs6dm8jUzqLa-lA2Wp8YtM3srVHOgNtSj5uRKfTZc7_5lZ4FWx8wFe_ESqizEdtC1tPXxHxTxXKw
Content-Type: text/plain

{

request : '{"dealerInfo":{"connId":"1730","dealerId":"40000148","dealerName":"Clear Home","dealerCode":"PFL7E","corpId":"60425","storeId":"1791538"},"orderInfo":{"orderNumber":"DS6665I23389211","orderDate":"2020-03-23T00:00:00Z","customerInfo":{"custType":"Residential","firstName":"Jaeff","lastName":"Srber","phone":"972-555=9205","altPhone":"","email":"uglx9@gmail.com","address1":"1725 WILLOW CRK","address2":"","city":"MESQUITE","state":"TX","zip":"75181-1590"},"videoInfo":{"provider":"DTV","componentCode":"ATT-COMP-DTV-ULT-ALL-INCL","package":"DIRECTV ULTIMATE All Included","orderNumber":"99-

TRUNCATED

VR with a Genie. Enjoy a full HD DVR experience in every room. Record any 5 shows at the same time, all in HD. Record up to 200 hours in HD.' style='padding-left:2px; padding-right:2px'>Genie</td><td class='emphasis' align='right'><span id='genieValue' style='color:green'>$0.00</span></td></tr><tr><td id='3genieminis' title='3 Genie Minis' style='padding-left:2px; padding-right:2px'>3 Genie Minis</td><td class='emphasis' align='right'><span id='3genieminisValue' style='color:green'>$0.00</span></td></tr><tr><td id='deliveryandhandling' title='DeliveryzderComments":{"value":""},"orderNotes":{"value":""}}}'

}

The response in POSTMAN:

{
    "Message": "No HTTP resource was found that matches the request URI 'http://localhost:29081/sforce/createworkorder'.",
    "MessageDetail": "No action was found on the controller 'Salesforce' that matches the request."
}


The underlying C# Controller (  NOTE:   The breakpoints I set in the controller constructor are hit ... the ones in CreateWorkOrder are not  )
using Clear.Core.Helpers;
using Clear.Core.Managers;
using NLog;
using Swashbuckle.Swagger.Annotations;
using System;
using System.Net;
using System.Web.Http;
using Clear.Core.Models.Salesforce;
using Clear.Core.Repositories;
using Clear.Core.Models.TransferModels;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace ClearSync.API.Controllers
{   
    [RoutePrefix("sforce")]  
    public class SalesforceController : ApiController
    {
        private readonly Logger _logger;
        private readonly ISalesforceManager _salesforceManager;
        private readonly ISalesforceClientHelper _salesforceClientHelper;
        private readonly ISalesforceRepository _salesforceRepository;
        private readonly ITerritoryHelper _territoryHelper;
        private readonly IPandoManager _pandoManager;


        public SalesforceController(ISalesforceRepository salesforceRepository, ISalesforceClientHelper salesforceClientHelper, ITerritoryHelper territoryHelper, IPandoManager pandoManager)
        {
            _logger = NLog.LogManager.GetCurrentClassLogger();
                      
            _salesforceClientHelper = salesforceClientHelper;
            _salesforceRepository = salesforceRepository;
            _territoryHelper = territoryHelper;
            _pandoManager = pandoManager;
        }


        [SwaggerOperation(Tags = new[] { "Salesforce" })]
        [SwaggerResponse(HttpStatusCode.OK, "", typeof(SalesforceAppointmentResponse))]
        [HttpPost, Authorize, Route("createworkorder")]
        public IHttpActionResult CreateWorkOrder(string request)
        {
            try
            {
                Order o = new Order();
                JObject jOrder = JObject.Parse(request);

                o.OrderInfo = new OrderInfo();
                o.DealerInfo = new DealerInfo();
                o.OrderInfo.OrderNumber = (string)jOrder["orderInfo"]["orderNumber"].ToString();
                o.OrderInfo.OrderDate = DateTime.Parse(jOrder["orderInfo"]["orderDate"].ToString());
                o.OrderInfo.CustomerInfo = JsonConvert.DeserializeObject<CustomerInfo>(jOrder["orderInfo"]["customerInfo"].ToString());
                o.OrderInfo.VideoInfo = JsonConvert.DeserializeObject<VideoInfo>(jOrder["orderInfo"]["videoInfo"].ToString());
                o.OrderInfo.InternetInfo = JsonConvert.DeserializeObject<InternetInfo>(jOrder["orderInfo"]["internetInfo"].ToString());
                o.OrderInfo.VoiceInfo = JsonConvert.DeserializeObject<VoiceInfo>(jOrder["orderInfo"]["voiceInfo"].ToString());
                o.OrderInfo.WirelessInfo = JsonConvert.DeserializeObject<WirelessInfo>(jOrder["orderInfo"]["wirelessInfo"].ToString());
                o.OrderInfo.AgentInfo = JsonConvert.DeserializeObject<AgentInfo>(jOrder["orderInfo"]["agentInfo"].ToString());

                string responseBack = _salesforceManager.CreateWorkOrder(o).Result;

                return Ok(new SalesforceAppointmentResponse()
                {
                    WorkOrderId = responseBack
                });
            }
            catch (Exception ex)
            {
                return BadRequest("Unable to create work order " + ex.ToString() + ex.InnerException.Message );
            }
        }

  
    }
}



EDIT:

I came across WebApiConfig.cs which looked helpful and "Route" like:

using System.Web.Http;
using ClearSync.API.Helpers;
using Newtonsoft.Json;

namespace ClearSync.API
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.MessageHandlers.Add(new CustomLogHandler());

            var jsonFormatter = config.Formatters.JsonFormatter;
            jsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}



What is this part:

routeTemplate: "api/{controller}/{id}",

and what is it describing?  The "api" is confusing to me because it does not show up in the URL (is not part of my request)
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros