Skip to main content
rishukumarg1965
Known Participant
May 5, 2025 11:43 AM UTC
Question

API is giving error invalid JSON format

I've created a web API that retrieves data from a process model, but when I call this API during integration,it returns the following error:
Error Code: errorIntegrationError
Title: Error processing integration response
Message: The response body could not be converted to an Appian value
Detail: The jsonText parameter was not valid JSON. Received: <...>.

I have attached the code

a!startProcess(
  processModel: cons!PDBPOC_gDrivePermissionPM,
  isSynchronous: true(),
  onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
      a!httpHeader(
        name: "Content-Type",
        value: "application/json"
      )
    },
    body: a!toJson(
      if(
        a!isNotNullOrEmpty(fv!processInfo.pv.userData),
        fv!processInfo.pv.userData,
        {
          message: "userData process variable is empty or not set."
        }
      )
    )
  ),
  onError: a!httpResponse(
    statusCode: 500,
    headers: {
      a!httpHeader(
        name: "Content-Type",
        value: "application/json"
      )
    },
    body: a!toJson(
      {
        error: "There was an error starting the process"
      }
    )
  ),
  onIncomplete: a!httpResponse(
    statusCode: 504,
    headers: {
      a!httpHeader(
        name: "Content-Type",
        value: "application/json"
      )
    },
    body: a!toJson(
      {
        error: "The process did not complete within the expected time"
      }
    )
  )
)

    2 replies

    shubhama926776
    Brainy
    May 5, 2025 11:57 AM UTC

    Mostly issue will be here : fv!processInfo.pv.userData

    Could you try to convert this into expression first.

    शुभम्
    mikes0011
    Brainy
    May 5, 2025 5:05 PM UTC

    If you switch to the "http request" tab, it'll show you (more plaintext) what the outgoing request was, which might help you troubleshoot.  We don't really have a way of knowing what was in pv!userData, so it's hard to guess at that.

    The Expression Guru