Layer7 API Management

Expand all | Collapse all

How to publish RESTful API (where are  fields with POST, payload...)

Jump to Best Answer
  • 1.  How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-24-2017 05:25 AM

    Hi,

    I would like to create and publish a RESTful API which is a REST POST command with a payload either application/json or application/xml

    I don't have wadl file.

    I would like to know the different steps to create this API in the CA Portal&GW and know which menu to use ?

     

    In CA API GW, I saw "publish web API" and "publish RESTful service proxy with WADL" menus. (not sure which to use) .

    I see a field to enter the URL but I don't find any field to enter the following :

    - POST / GET / DELETE

    - payload

    - application / json or application / xml

     

    Please advice.

    Thanks,

     

    Corinne



  • 2.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-24-2017 12:51 PM

    Corinne,

     

    Good afternoon. Being that you do not have a WADL you will need to use the Publish Web API (Publish Web API - CA API Gateway - 9.2 - CA Technologies Documentation ) menu option when you right click on the bottom right hand pane of the Policy Manager. Step through the basic settings and finish the initial setup. Afterward you can can right click on newly created service and select Service Properties then the HTTP/FTP tab to choose what HTTP Methods to allow.

     

    As for the content-type, we support a large number textual based ones if deep inspection of the payload is required and we also can pass through binary and other data. If you want to filter content-type of what is allowed then you can use the Validate or Change Content-Type assertion in your policy.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 3.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-24-2017 06:21 PM

    Following your suggestion , I used Publish Web API and Stepped through the basic settings. Selecting Properties then the HTTP tab, I chose "HTTP Routing Properties"  and HTTP POST Method (see attached screenshot1).

    Still not clear for me where/how to put the content-type and the payload (see attached screenshot2)

     

    Thanks for your support,

     

    Corinne



  • 4.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-25-2017 04:54 AM


  • 5.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 12:45 PM
      |   view attached

    Hi,

     

    Thanks for your answer.

    I tried to use it. But not sure how.

    I also tried to use the suggestion from Seenu Mathew below.

    I'm not sure if it was a complementary suggestion with your .

    See 3 attached slides.

    Let me know your comment and how to add the "POST response".

     

    Thanks,

     

    Corinne

    Attachment(s)



  • 6.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 12:56 PM

    Corinne,

     

    The slides does not appear to be attached to your post.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 7.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 01:08 PM
      |   view attached

    Sorry, here are the slides.

    Regards,

    Corinne

    Attachment(s)



  • 8.  Re: How to publish RESTful API (where are  fields with POST, payload...)
    Best Answer

    Posted 04-25-2017 10:31 AM

    Hi corinne.sayag,

     

    You can create a context variable of type message for the payload. The content type can be specified when defining the variable. To use this in the routing assertion simply change the field for 'request source' to the variable defined above.

     

     

    Regards,

    Joe



  • 9.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 01:04 PM

    Thanks for your answer.

    I tried to use it. But not sure how.

    I also tried to use the suggestion from Seenu Mathew below.

    I'm not sure if it was a complementary suggestion with your .

    See 3 attached slides.

    Let me know your comment and how to add the "POST response".

     

    Thanks,

     

    Corinne



  • 10.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 01:17 PM

    Corinne,

     

    This post is going in a few different directions so let try to knock each off at a time. From your original request there was 4 requests:

    1) In CA API GW, I saw "publish web API" and "publish RESTful service proxy with WADL" menus. (not sure which to use) .

    Response: Use the Publish Web API option

    2) I see a field to enter the URL but I don't find any field to enter the following :

    a) POST / GET / DELETE

    Response: Modify the service property and select the HTTP/FTP tab to choose the allowed methods

    b) payload

    Response: I believe this is the only outstanding question.  Would you be able to elaborate on whether you are talking about inbound payload from the client or what is returned in the response payload? Any addition insight would help point you in the right direction.

    c) application / json or application / xml

    Response: This can be controlled using the Validate or Change Content-type assertion in the policy.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support

     



  • 11.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 04-28-2017 08:06 PM

    Hi,

     

    Thanks for your mail . See my comments below

    1/ It answers my question : Thanks !

    2/ a/ It answers my question : Thanks !

    2/ b/ In fact, you are right : I have two questions here.

     

    The API I want to describe is

     

       

    •   a POST with a payload (see first screenshot below)  => what you call the inbound payload

     

    and

     

       

    •   a Response to this POST with a payload (see second screenshot below) => what you call the response payload

    So, my question is how to describe

     

       

    •   the POST with the payload (I think I did it in the slide 2 and 3 of my previous mail : please confirm it is done properly)

       

    •   the response to this POST with its payload : I don’t know where to enter this response and its payload.

    Please advice.

     

     

     

     

     

     

     

     

    2/ c/ It answers partially my question : I tried to use the Validate or Change Content-type assertion in the policy, but I’m not sure I used it properly. See my slide1 in previous mail. Let me know if I used it properly.

     

    Thanks a lot for your precious answers.

     

     

    Regards,

     

    Corinne



  • 12.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 05-01-2017 06:37 PM

    Corrinne,

     

    Thank you for the clarification. I think one point that is being missed here is that the policy itself does not need to have the payload configured as it is intended to receive it from the client sending in a payload. When the gateway receives the payload from the client it will gather a bunch of different settings such as the request payload, headers, parameters, URL., URI, etc. These values can then be used in the policy to either make decisions or to forward through to back end systems. If you are not hard coding the request to be sent through to the back end you do not need to change the target message in the HTTP Routing assertion. This does not mean you can not set a static payload in the policy say if you want to transition from REST to SOAP or another format but it is not required. This also is the same for the response from the HTTP Routing assertion as the gateway will take what is provided by the back end through the assertion directly back to the client if no other policy logic acts against it.

     

    As for validate that the content-type is what is expected then you need to use regular expression to validate against the context variable request.contenttype. Sample Assertion snippet:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
        <wsp:All wsp:Usage="Required">
            <L7p:Regex>
                <L7p:AutoTarget booleanValue="false"/>
                <L7p:OtherTargetMessageVariable stringValue="request.contenttype"/>
                <L7p:Regex stringValue="application/json.*|application/xml.*"/>
                <L7p:RegexName stringValue="Validate Known Good Content Types"/>
                <L7p:Replacement stringValue=""/>
                <L7p:Target target="OTHER"/>
            </L7p:Regex>
        </wsp:All>
    </wsp:Policy>

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 13.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 05-05-2017 11:12 AM

    Thanks for your answer. Sorry, It is still not clear for me. I will try to read your answer again, and come back to you if still not clear.

    Regards,

     

    Corinne



  • 14.  Re: How to publish RESTful API (where are  fields with POST, payload...)

    Posted 05-11-2017 11:52 AM

    Hi Stephen,

    Sorry, but I don't understand your answer. 2/b/ and 2/c/ are still not clear for me.

    As I sent some screenshots in previous mail in attachment CAquestion_how_enter_RESTAPI_response.pptx, please could you comment these slides, and if not correct, please could you put screenshot of what you suggested ? This could be very helpful for me to understand more easily your answer.

    Thanks a lot,

    Corinne