Forum Discussion

ADS_PSI's avatar
ADS_PSI
Mentor
7 years ago

Create a endpoint which is of POST type

Hi,

 

Normally when we create endpoint and expose it to third party it is of method GET. Can we create endpoint for POST type ?

  • ADS_PSI I have heard someone has used PHP CURL function to make a http POST action to the lithium endpoint. It should work. If you are using chrome Postman extension for testing, it may not work. You may need to ask Lithium support to enable something. I believe there may be a whitelist IP table.
    • ADS_PSI's avatar
      ADS_PSI
      Mentor

      We can have post call to endpoints but we want to create endpoint which will be of POST type , exposed to third party. How can we make it ?

      • VikasB's avatar
        VikasB
        Boss

        ADS_PSI  What I am getting here is that you are trying to use post-call on third-party inside the endpoint. Correct me if I am wrong. 
        You can use post call in endpoint also. Make sure you are sending the content type also to avoid the roadblocks. Content type "application/x-www-form-urlencoded" means that your POST body will need to be URL encoded just like a GET parameter string.

        Here is the syntax

        <#assign http_client_request = http.client.request("https", "base_path", "api_url").body("param1=${value}","application/x-www-form-urlencoded").post() />
        <#if http_client_request.hasError>
        ${http_client_request.error.message}
        <#else>
        ${http_client_request.content}
        </#if>