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

  • 0
    Certified Lead Developer
    in reply to Rochester

    So, my typical approach is, to reduce complexity when I am stuck. Build a separate test interface with just the minimum things. Then I suggest to save the whole API response to a local variable. Then drill into it, step by step. It is so easy to get this wrong.

  • As suggested, I tried to create a simple test-interface .... But I am trying to figure out how to display the result returned by the integration because I am getting the following errors

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!richTextDisplayField [line 5]: A rich text item or rich text list item in a rich text display component [label=""] has an invalid value for "text". Text can only be of type date, date and time, decimal, rich text icon, integer, rich text item, text, time, or user. Received RichTextDisplayField.

    {
      a!localVariables(
        local!integrationResponse,
        a!formLayout(
          a!richTextDisplayField(
            labelPosition: "COLLAPSED",
            value: {
              a!richTextItem(text:local!integrationResponse)
            }
          ),
          a!buttonArrayLayout(
            buttons: {
              a!buttonWidget(
                label: "Submit Test Data",
                style: "OUTLINE",
                saveInto: {
                  rule!CreatePatientResource(
                    givenName: "Susan",
                    familyName: "James",
                    gender: "Female",
                    dateOfBirth: "1989-02-23",
                    onSuccess: {
                      a!save(local!integrationResponse, fv!result)
                    },
                    onError: {
                      /*Handle HTTP error */
                      a!save(
                        local!integrationResponse,
                        fv!error.message
                      )
                    }
                  )
                }
              )
            },
            align: "START",
            marginBelow: "NONE"
          )
        )
      )
    }

  • 0
    Certified Lead Developer
    in reply to Rochester

    Hello  ,

    It appears you have missed the keywords on your form layout on the code you shared.
    Try this and check if you get any data on your local!integrationResponse and share here if you need help diagnosing this further

    a!localVariables(
        local!integrationResponse,
        a!formLayout(
          contents:{
            a!richTextDisplayField(
            labelPosition: "COLLAPSED",
            value: {
              a!richTextItem(text:tostring(local!integrationResponse))
            }
          ),
          a!buttonArrayLayout(
            buttons: {
              a!buttonWidget(
                label: "Submit Test Data",
                style: "OUTLINE",
                saveInto: {
                  rule!CreatePatientResource(
                    givenName: "Susan",
                    familyName: "James",
                    gender: "Female",
                    dateOfBirth: "1989-02-23",
                    onSuccess: {
                      a!save(local!integrationResponse, fv!result)
                    },
                    onError: {
                      /*Handle HTTP error */
                      a!save(
                        local!integrationResponse,
                        fv!error.message
                      )
                    }
                  )
                }
              )
            },
            align: "START",
            marginBelow: "NONE"
          )
          }
        )
      )