Call POST API from GET API

Hi All,

I have two APIs right now. POST webAPI and GET Webapi.

--POST API is taking two query params as input, doing a start process and returning some url in its body.

--In GET Api i want to fetch that url from POST APIs body. How can I pass the params to POST Api from my GET API to fetch the url as response in GET API?

Here is my current implementation in GET API:

a!localVariables(
  local!httpRequestBody:http!request.queryParameters,
  local!FormId: if(
    rule!GEN_IsNull(local!httpRequestBody),
    null,
    local!httpRequestBody.FormId
  ),
  local!formToLaunchParameters_txt: if(
    rule!GEN_IsNull(local!httpRequestBody),
    null,
    local!httpRequestBody.formToLaunchParameters_txt
  ),
  if(
    or(
      rule!GEN_IsNull(local!FormId),
      rule!GEN_IsNull(local!formToLaunchParameters_txt)
    ),
    a!httpResponse(
      statusCode: 500,
      headers: a!httpHeader(
        name:"Content-Type",
        value:"application/json"
      ),
      body:a!toJson(
        {
          error:"FormId or KeyInstn is missing"
        }
      )
    ),
    a!httpResponse(
      statusCode: 301,
      headers: a!httpHeader(
        "Location",
        rule!LinkToLaunchForm(----------This is the POST API
        )
      )
    )
  )
)

  Discussion posts and replies are publicly visible

Parents Reply Children
  • But the issue is even if i create integration for it, how we will use this integration outside appian? the use case here is that I want to trigger a process model that resides in appian from outside appian and as a result I want the response. Through Integration Its not achievable as its an appian object I cannot use it outside appian. but using the GET webapi and this httppost() function I am able to achieve this. what other option do I have apart from this?

  • 0
    Certified Lead Developer
    in reply to Sadia_Rashid

    So, while not recommended, you can do the following:

    External System -> GET -> Appian Web API -> Appian Integration (*) -> POST -> Appian Web API

    * Why not recommended? When you configure a POST integration you set the "Usage" parameter. When set to "Queries Data", you can call that integration from any Appian interface or Smart Service. When set to "Modifies Data", you can use it only inside a saveInto, a Smart Service, or inside a POST Web API. So you have to falsely configure it to "Queries Data" even if it starts a process that updates data in the system.