Layer7 API Management

  • 1.  how to declare query parameters in API service?

    Posted Dec 21, 2016 12:15 PM

    how to declare query parameters in API service from Policy Manager?

     

    And how to access them within the policy to check if parameter values are null?

     

    Example: 

    Service URL is suppose to be:

    https://host:port/company/v1/employees/profile?phoneNumber=23232$emailId=sample@email.com

    Method GET.

     

    What are the context variables to access these query parameters. 

     

    my validation with in policy is 

       If phoneNumber = null and emailId = null 

          Respond with Bad Request error message without routing to backend service.

    else 

       map corresponding paramters to the backend service.

     

     

    Regards

    Kareem



  • 2.  Re: how to declare query parameters in API service?
    Best Answer

    Posted Dec 21, 2016 01:11 PM

    https://docops.ca.com/ca-api-gateway/9-2/en/reference/context-variables/transport-layer-context-variables 

     

    You can use this ${request.http.parameter.<ParamName>}, similarly u can use this for headers ${request.http.header.<headerName>}

     

    hope this helps,

     

    Doyle



  • 3.  Re: how to declare query parameters in API service?

    Posted Dec 21, 2016 01:28 PM

    Thanks for quick reply Doyle. 

     

    I will try with provided information for accessing query parameters. 

    Can you also provide information on how to declare query parameters for service?

     

    Is it enough to declare as below for Custom Resolution Path in Service Properties?

       Custom Resolution Path = company/v1/employees/profile*

    Is it equal to below URLs?

    company/v1/employees/profile?phoneNumber=23232$emailId=sample@email.com

    company/v1/employees/profile?phone=123

    company/v1/employees/profile?xyz=sample&zyx=sample2&abc=11212

     

    Is it safe to declare in this way as it can accepts any undefined parameters? Don't we have any declaring for specific query parameters?

     

    Provided URL is not accessible. 403 Forbidden Error.

     

    Regards

    Kareem



  • 4.  Re: how to declare query parameters in API service?

    Broadcom Employee
    Posted Dec 21, 2016 01:40 PM

    Kareem,

     

    The URI for Custom Resolution Path = company/v1/employees/profile* does not look at the query parameters being sent through as part of its resolution path just the URI. The standard structure of the query parameter so that the gateway can pick it up is ?para1=1234&para2=abcd which in turn will be automatically set to ${request.http.parameter.para1} and ${request.http.parameter.para2}. The dollar sign is not viewed a delimiter to outline different query parameters.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 5.  Re: how to declare query parameters in API service?

    Posted Dec 21, 2016 01:41 PM

    yes, Parameters aren't taken into account for service resolution.  A 403 is an Authorization error, so more than likely, you are resolving, but aren't authorized.