Parsing HTTP Response

I am struggling with parsing the HTTP response.  I thought fv!result in the rule that called the integration would allow me to access the body of the response.  However, I am getting errors.  The three values I am trying to access are highlighted below.  Screenshots of the function where I call the integration and the response from the call are shown below.  I would like the three values stored in local variables so I can display the text messages to the user.  Thank you in advance!

                         rule!CreatePatientResource(
                           givenName:local!firstName,
                           familyName:local!surName,
                           gender:local!gender,
                           dateOfBirth: local!dateOfBirth,
                           onSuccess:
                           {
                             a!save(local!registrationErrorMessage,null),
                             a!save(local!registrationComplete,true()),                 
                             a!save(local!registrationConfirmationMessage, 
                               concat(tostring(local!firstName), " ",tostring(local!surName)," was successfully registered"))

                           },
                           onError: {
                              /*Handle HTTP error */
                             a!save(local!registrationErrorMessage, fv!error.message)
                           }
                         )

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    And what errors do you get?

    For me, your code and your requirements do not match.

    Where is this "onSuccess" coming from. Do you try to call an integration which you configured to "Modifies Data" just inside some expression code?

  • The onSuccess/onError was shown as rule-inputs when we selected "Override and define all error conditions" option.  

    This is the integration that we are trying to call and obtain results from.

  • 0
    Certified Lead Developer
    in reply to Rochester

    OK. And the other questions from my post?

    When you configure that integration to "Usage: Modifies Data", you can only call it inside a saveInto or a Call Integration node in a process. And this is when the onSuccess and onError pop up.

  • Error:Could not display interface. Please check definition and inputs.  Interface Definition: Expression evaluation error:

    Here is the sequence 

  • 0
    Certified Lead Developer
    in reply to Rochester

     
    Error:Could not display interface. Please check definition and inputs.  Interface Definition: Expression evaluation error:

    This error appears to be more with how the data is being handled after your integration call.

    Your code for calling the integration itself appears to be good.

    If you could share the code for your interface that would help diagnose the problem

  • 0
    Certified Lead Developer
    in reply to Rochester

    In your code, in the onSuccess, I do not see that you try to fetch any data from the API call result.

    Find here the documentation about how to call an integration.

    https://docs.appian.com/suite/help/24.1/Call_an_Integration.html

    Then, I suggest to create a very simplified test interface to make a root cause analysis easier.

  • Hello Naveen:

    Here is the code.... If I remove the highlighted line, it works but I need the ID from the integration's response (see image from previous post). 

    Thank you for your help.

    a!sectionLayout(
    label: "Patient Information",
    contents: {
    a!textField(
    label: "First Name",
    labelPosition: "ABOVE",
    placeholder: "Enter Patient's Given Name",
    value: local!firstName,
    saveInto: {
    local!firstName,
    a!save(local!registrationErrorMessage, null)
    },
    refreshAfter: "KEYPRESS",
    required: true,
    disabled: local!registrationComplete
    ),
    a!textField(
    label: "Family Name",
    labelPosition: "ABOVE",
    placeholder: "Enter Patient's Surname Name",
    value: local!surName,
    saveInto: {
    local!surName,
    a!save(local!registrationErrorMessage, null)
    },
    refreshAfter: "KEYPRESS",
    required: true,
    disabled: local!registrationComplete
    ),
    a!textField(
    label: "Gender",
    labelPosition: "ABOVE",
    placeholder: "Enter Patient's Gender",
    value: local!gender,
    saveInto: {
    local!gender,
    a!save(local!registrationErrorMessage, null)
    },
    refreshAfter: "KEYPRESS",
    required: true,
    disabled: local!registrationComplete
    ),
    a!dateField(
    label: "Date of Birth",
    labelPosition: "ABOVE",
    value: local!dateOfBirth,
    saveInto: {
    local!dateOfBirth,
    a!save(local!registrationErrorMessage, null)
    },
    required: true,
    disabled: local!registrationComplete
    ),
    a!textField(
    label: "Student Identifier",
    labelPosition: "ABOVE",
    placeholder: "Enter Student Identifier",
    value: local!studentIdentifier,
    saveInto: {
    local!studentIdentifier,
    a!save(local!registrationErrorMessage, null)
    },
    refreshAfter: "KEYPRESS",
    required: true,
    disabled: local!registrationComplete
    ),
    if(local!registrationComplete,
    {
    /* */
    a!richTextDisplayField(
    value: {
    a!richTextImage(image: a!documentImage(document: a!iconIndicator(icon: "STATUS_OK"))),
    a!richTextItem(text:local!integrationResponse, color:"ACCENT", size:"MEDIUM")
    /*a!richTextItem(text:"has been successfully registered", size:"MEDIUM"),*/
    }
    ),
    a!richTextDisplayField(
    value: {
    a!richTextImage(image: a!documentImage(document: a!iconIndicator(icon: "STATUS_OK"))),
    a!richTextItem(text:local!registrationConfirmationMessage, color:"ACCENT", size:"MEDIUM")
    /*a!richTextItem(text:"has been successfully registered", size:"MEDIUM"),*/
    }
    ),
    },
    a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Register Patient",
    saveInto: { {
    rule!CreatePatientResource(
    givenName:local!firstName,
    familyName:local!surName,
    gender:local!gender,
    dateOfBirth: local!dateOfBirth,
    onSuccess:
    {
    a!save(local!registrationErrorMessage,null),
    a!save(local!registrationComplete,true()),
    a!save(local!registrationConfirmationMessage,
    fv!result.headers.location),
    /*concat(*/
    /*tostring(local!firstName),*/
    /*" ",*/
    /*tostring(local!surName),*/
    /*" was successfully registered"*/
    /*)*/
    a!save(local!integrationResponse, fv!result.body.id)

    },
    onError: {
    /*Handle HTTP error */
    a!save(local!registrationErrorMessage, fv!error.message)
    }
    )
    }
    },
    style: "SOLID",
    disabled: not(isnull(local!registrationErrorMessage)),
    loadingIndicator: true,
    validate: true
    )
    }
    )
    )
    },
    validations: if(isnull(local!registrationErrorMessage),
    {},
    local!registrationErrorMessage
    )
    )

  • 0
    Certified Lead Developer
    in reply to Rochester

    What do you mean with 

    If I remove the highlighted line, it works

    What does work? Do you see any error message?

    That line looks good for me.

  • 0
    Certified Lead Developer
    in reply to Rochester

     ,

    Your code looks good and I dont see any problem . Since you are getting the response from your headers after the integration to debug it will be worth capturing the whole response from fv!result to your local variable instead of indexing it right away and check if the response is indeed as you are expecting it to be.

  • The interface works - I don't see any error message.

Reply Children