Forum Discussion

cesarvidril's avatar
11 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

6 Replies

  • 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
    11 years ago

    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() />

     

  • Yes i readed this.

     

    Now i have a endpoint, who make a post with this client request, the url point to another endpoint.

    How, in that second endpoint, i get the data send by the first endpoint?

  • NicoB's avatar
    NicoB
    Lithium Alumni (Retired)
    11 years ago

    nathan 

    to answer your question, you can user http.client only on whitelisted domains.

    However Lithium is one domain which is not supported therefore you cannot use http.client to invoke anything in Lithium.

     

    Nico