Skip to main content
rishukumarg1965
May 5, 2025
Question

API is giving error invalid JSON format

  • May 5, 2025
  • 2 replies
  • 0 views

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
    May 5, 2025

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

    Could you try to convert this into expression first.

    mikes0011
    Brainy
    May 5, 2025

    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.