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
  • I have done it through httppost request. like this: 

    local!postRequest: httppost(
    endpoint: concat(
    cons!SITE_URL,
    cons!ENDPOINT
    ) & "Key=" & local!Key
    headerNames: {cons!API_AUTHORIZATION_KEY},
    headerValues:{cons!API_AUTHORIZATION_KEY_HEADER_VALUE}

    ),

    and its working fine. Can you now tell how can I pass two query params here? Its working fine with only one param here but if I pass a second param aslo, it throws an error. I want to do something like this:

    endpoint: concat(
    cons!SITE_URL,
    cons!ENDPOINT
    ) & "Key=" & local!Key
    & "FormId=" & local!FormId,

Children