Skip to main content
stephaniek0003
April 24, 2024
Question

Docusign Webhook POST API - how to get body?

  • April 24, 2024
  • 11 replies
  • 0 views

Hi All - I've created an integration with Docusign and have configured the Web API to receive a response from Docsign when the document is signed. Docusign responds and successfully kicks off the process, but I can't figure out how to pull the envelopeid and documentid from the message response.  I've got the sample code that converts the http!request.body from json to a processparameter. But I can't figure out how to get the data from there? I've tried converting to process variables and various settings within the Start Trigger panel, but haven't been able to see the message body/data anywhere.

Any guidance would be appreciated.

    11 replies

    stefanhelzle0001
    April 24, 2024

    When you follow the built in Web API example "Start Process", most of the things should already be set up. Can you share the code of the web API Appian object?

    Not sure what you mean with "Start Trigger Panel" ...

    stephaniek0003
    April 24, 2024

    here's the code that came with the start process Web Api.  I see the http!request body is supposed to get populated into the processParameters dictionary, but I can't figure out how to access it from there.

    By "Start Trigger Panel", I was playing with the Start options in the process, to see if I was supposed to configure the message body into something there.

    a!startProcess(
      processModel: cons!WMO_Docusign_Receive,
      processParameters: a!fromJson(
        http!request.body
      ),
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(name: "Content-Type", value: "application/json")
        },
        body: a!toJson(
          fv!processInfo
        )
      ),
      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"
          }
        )
      )
    )

    stephaniek0003
    April 24, 2024

    And if I manally paste the Docusign http body into my API configuration Test screen, it does convert it properly. I just don't know how to access that in the process.

    srmm0001
    April 25, 2024

    Hi, 

    In your Appian process model, create a variable of type Text or dictionary to receive the raw JSON payload. Modify your Web API to pass http!request.body directly into the process variable you created.. In your process model, parse the JSON from the Text variable into a Dictionary using a!fromJson() within a Script Task.and after parsing, extract envelopeId and documentId from the Dictionary variable in subsequent Script Tasks or Gateways.

    a!startProcess(
    processModel: cons!WMO_Docusign_Receive,
    processParameters: { jsonText: http!request.body },
    onSuccess: a!httpResponse( /* success response */ ),
    onError: a!httpResponse( /* error response */ )
    )

    And in your process model, you would have a parameter, let's say jsonText, to capture the raw JSON. Then, in the first Script Task.

    local!jsonData: a!fromJson(local!jsonText),
    local!envelopeId: local!jsonData.envelopeId,
    local!documentId: local!jsonData.documentId

    ---By doing this, the process starts with the complete JSON payload, which you then parse and manipulate within the process model.

    if this solution is not working , please ignore 

    stephaniek0003
    April 25, 2024

    OK, thanks for all the details and suggestions.  I was able to get the entire body into the process either as the straight json, or converted using a!fromjson. Both of those options work to get the text into a variable. BUT, I'm still not able to figure out how to parse and extract fields. (I did accomplish the same by using regex patterns, but that's not the best approach for a formatted file!).

    I wonder if it's b/c the json is nested into sections?  how would I notate the extract as the json looks like this - I need the object / data / envelopeId:

    Thanks again for the help!

    stefanhelzle0001
    April 25, 2024

    fromJson turns the JSON string into an Appian dictionary in which you can navigate using dot-notation

    data.envelopeSummary.status

    iann8900
    May 3, 2024

    Hi Steph, how did you set up the webhook on the DocuSign side? I'm in the middle of creating this same thing on a project and struggling to get the Webhook to connect. Nevermind! Got it working :)

    vinayj0006
    May 11, 2024

    Hi nish,

    Could you please me in understanding the webhook connection steps and for events like Envelope complete we have to hits a web API in Appian to start a process model.

    Iam trying since so long but I could able to complete.