Docusign Webhook POST API - how to get body?

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.

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 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"
          }
        )
      )
    )

  • 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.

  • 0
    Certified Lead Developer
    in reply to StephK

    I understand. I think the example code is a bit ... unfortunately chosen.

    It just passes the decoded JSON structure to the process. Now, the process model needs to provide multiple process variables, configured as parameters, to accept the individual top level values.

    So, if the JSON response looks like this:

    {
      "alpha": "one",
      "beta": {
        "one": 1,
        "two": 2
      },
      "gamma": 12345
    }

    ... your process needs three parameter variables alpha, beta and gamma of the types Text, Map and Integer.

    You could also change the code in the API to pass the whole structure into a single variable.

    processModel: cons!WMO_Docusign_Receive,
    processParameters: {
      your_process_variable: a!fromJson(
        http!request.body
      )
    }

    ... then create one process variable named "your_process_variable" of type Map and make it a parameter.

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    I would actually suggest not doing a!fromJson before starting the process (in the odd event that there is something wrong with the json that was sent) that prevents the process from starting.

    Have one start parameter for your process (i.e. json) and parse the json using a!fromJson in a script task.

  • 0
    Certified Lead Developer
    in reply to Mathieu Drouin

    That has the drawback that, in case the JSON is invalid, you have a failed process instance you need to take care of.

    I try to add input data validation code directly to the API to only start further processing if the incoming data is good.