Forum Discussion

cesarvidril's avatar
10 years ago

Endpoint and POST Request

Hi

 

I want to know if it is possible to get data from a POST request in endpoints.

At the moment we use http.request.parameters.name.get("label","") to have data wit GET request but want to send data not via URL but via POST method.

 

Is it possible? How to achieve it?

 

Thanks

    • Hi Nathan, thanks for the reply.

      Now if wan't to get the data sent in POST method to my endpoint, how to do it?

       

      To be more specific, i have an external service who will post ajax datas to my endpoint.
      I don't know how to get thoses data.

      • nathan's avatar
        nathan
        Executive

        If you read the page carefully, it explains how to do this.

         

        http.client.request(...) returns a request object. You can run various methods on this object before make the call out to the external web service. These include:

        • Adding parameters via the parameter() method
        • Adding a fragment via the fragment() method
        • Adding cookies via the cookie method()
        • Adding body content to the request using the body() method

         

        When you've used these methods to add anything you need to the request, you execute the request using one of the methods: get, post, put, ...

         

        Here is a code example (taken straight from the page). It creates a request, adds the body content, and executes the HTTP POST method:

        <#assign http_client_request = http.client.request("http", "www.somewebservicedomain.com", "/some/web/service").body("{ 'application':'lithium', 'user':'johnD' }", "application/json").post() />