Forum Discussion

Rajesh's avatar
Rajesh
Icon for Nimbostratus rankNimbostratus
Sep 12, 2018

jason response

Hi,

 

There is an requirement to return a jason response message for an application contains an context (/applicationname) .. Please help how do i implement it as irule

 

3 Replies

  • use the HTTP::respond command - set the content-type to application/json and send the response. Is it always the same? If it is large then you can add it as an iFile and send that directly.

     

  • Use HTTP::respond

    eg

    when HTTP_REQUEST {
        HTTP::respond 200 -version 1.1 content { { "name": "Pete White" } } Content-Type application/json
        }
    

    Note that the use of curly brackets

    { }
    around content means that there will be no variable interpolation. You can also use speech marks
    ""
    as well.

    Lots of good examples if you get stuck.