locked
custom web api controller is not getting invoked from Apiclient RRS feed

  • Question

  • Hi ,

    i have added new webapi controller  to the api project and
    modified the webapirouteconfig 
      config.Routes.MapHttpRoute(
                 name: "NameResolution",
                 routeTemplate: "{securitygroups}/nameresolution",
                 defaults: new { controller = "NameResolution" });

    and i have httpget method in the Nameresolutioncontroller.cs

    [HttpGet] public SecurityGroupResult ValidateSecurityGroup(string securitygroups)

     



    now when this is called from apicleint project from Tenant Ui as below

    private async Task<T> GetAsync<T>(Uri requestUrl)        {                     var response = await this.HttpClient.GetAsync(requestUrl, HttpCompletionOption.ResponseHeadersRead);            response.EnsureSuccessStatusCode();            return await response.Content.ReadAsAsync<T>();        }


    it throws error as below...
    httpStatusCode":"InternalServerError","operationTrackingId":"","stackTrace":"System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).\r\n at 


    should i register this route somewhere in powershell file ??? 

    Can i register a custom route as i mentioned above cos the powershell has only the below routes

     'TenantSourceUriTemplate' = '{subid}/services/CmpWapExtension/{*path}';
        'TenantTargetUriTemplate' = 'subscriptions/{subid}/{*path}';


    • Edited by shiv455 Monday, October 6, 2014 7:34 PM
    Monday, October 6, 2014 7:32 PM

Answers

All replies

  • What is the generate URL looking like on API client?

    I will change the URL template to probably "nameresolution/{securitygroup}", so that system can do the routing easily. If the first part it a variable, then not sure how it works. If you change the route template, remember to change the URL template in API client as well.

    Monday, October 6, 2014 7:45 PM
  • Also, I haven't tested case sensitivity. So you might want to make sure that it also matches.
    Monday, October 6, 2014 7:46 PM
  • After modifying as suggested the generated url is as below

    https://xxxx:30005/services/MyExtension/nameresolution/mygroup

    routetemplate is

       config.Routes.MapHttpRoute(
                 name: "NameResolution",
                 routeTemplate: "nameresolution/{securitygroups}",
                 defaults: new { controller = "NameResolution" });

    still it throws the same error...

    in powershell the route is mentioned as below

     'TenantSourceUriTemplate' = '{subid}/services/CmpWapExtension/{*path}';
        'TenantTargetUriTemplate' = 'subscriptions/{subid}/{*path}';

    is this the reason for the issue??

    • Edited by shiv455 Monday, October 6, 2014 8:45 PM
    Monday, October 6, 2014 8:42 PM
  • If atleast one message is routing correct for tenant, then your resource provider configuration is good. Can you check http://manesh.me/2014/10/07/troubleshoot-message-flow-for-windows-azure-pack/ and see if you are able to see if & what message lands on your RP?
    • Proposed as answer by kittu455 Wednesday, October 8, 2014 4:45 PM
    • Marked as answer by shiv455 Tuesday, October 14, 2014 5:12 AM
    Tuesday, October 7, 2014 8:29 AM
  • when I changed the route as below it started invoking the webapi controller..

    config.Routes.MapHttpRoute(

                 name: "NameResolution",

               routeTemplate: "subscriptions/{subscriptionId}/nameresolution/{securitygroups}",

                 defaults: new { controller = "NameResolution" });

    • Proposed as answer by kittu455 Wednesday, October 8, 2014 4:45 PM
    Wednesday, October 8, 2014 4:45 PM