Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventNotification - Webhook - JSON #130

Open
adrienlamotte opened this issue Feb 10, 2021 · 2 comments
Open

EventNotification - Webhook - JSON #130

adrienlamotte opened this issue Feb 10, 2021 · 2 comments

Comments

@adrienlamotte
Copy link

Hello,

I'm using EventNotification class to define my webhook. I can see you can choose between XML/JSON when I use the website to create the hook :

image

But I can't find a way to ask for JSON when creating the hook programmatically like :

    $eventNotification = new EventNotification();
    $eventNotification->setUrl('https://webhook.site/123456');
    // How to ask for JSON ?

Is this possible?
Thanks for you help!

@EdwinMoralesDS
Copy link

You can change the format from XML to JSON by adding eventData to your eventNotification object

The event data should contain the following information:

"eventData":{
         "version": "restv2.1",
         "format": "json",
         "includeData":  ["tabs","payment_tabs","custom_fields","powerform","recipients","folders","extensions","attachments","Documents"]
},

You can change "includeData" to contain only the information you want included in your notification

This is the class you should be using for this:
https://github.com/docusign/docusign-php-client/blob/82fddd73429e0b86ea82f503c7831d8541f049a5/src/Model/ConnectEventData.php

@DeanWard
Copy link

DeanWard commented Sep 20, 2023

For anyone else battling this I finally worked it out but I thought that Edwin's comment could have been more helpful. This is how I ended up getting it to behave in the way I wanted.

I don't know if everything here is required but now it's working I'm not messing with it!

private function createEventNotification()
    {
        
        $eventData = new \DocuSign\eSign\Model\ConnectEventData();
        $eventData->setVersion('restv2.1');
        $eventData->setFormat('json');
        $eventData->setIncludeData(['custom_fields', 'tabs', 'recipients', 'powerform_data' ]);

        $eventNotification = new \DocuSign\eSign\Model\EventNotification([
            'url' => env('DS_WEBHOOK_URL'),
            'event_data' => $eventData,
            'delivery_mode' => 'SIM',
            'logging_enabled' => 'true',
            'include_documents' => 'false',
            'use_soap_interface' => 'false',
            'envelope_events' => [
                new \DocuSign\eSign\Model\EnvelopeEvent([
                    'envelope_event_status_code' => 'completed'
                ])
            ]
        ]);
        return $eventNotification;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants