Custom Event Hooks

The HTTP & Python API
mitchell.lotierzo
Posts: 17
Joined: December 16th, 2016, 8:16 pm

Custom Event Hooks

Postby mitchell.lotierzo » August 21st, 2017, 3:52 pm

Has there been any thought to opening up the new event hook functionality so studios can create their own custom event hooks? For example, I'm needing to make an event hook for when a user adds a file on an asset through the NIM portal.

Thanks!
Mitch

andrew
Site Admin
Posts: 179
Joined: June 24th, 2014, 8:10 am

Re: Custom Event Hooks

Postby andrew » August 21st, 2017, 7:54 pm

Hi Mitch,

Unfortunately there isn't a way to allow end users to define their own hooks as the hooks need to be triggered in the source code, but we're happy to add the hooks as needed. We will add the hook you need and get it to you in the next update.

Thanks,
Andrew

mitchell.lotierzo
Posts: 17
Joined: December 16th, 2016, 8:16 pm

Re: Custom Event Hooks

Postby mitchell.lotierzo » August 23rd, 2017, 1:23 pm

That would be great because we are running into an issue where I customized the connector code to correct filenames a certain way. However, when files are added through the web portal, those customizations are not respected.

mitchell.lotierzo
Posts: 17
Joined: December 16th, 2016, 8:16 pm

Re: Custom Event Hooks

Postby mitchell.lotierzo » December 21st, 2017, 5:54 pm

How can I query the API in an event hook when using API keys? Right now, the event code isn't triggering because it's complaining about not being able to find the API Key.

andrew
Site Admin
Posts: 179
Joined: June 24th, 2014, 8:10 am

Re: Custom Event Hooks

Postby andrew » December 21st, 2017, 8:20 pm

You'll need to pass a user and api key in the example nimAPI() function. You can do this by adding the appropriate headers to the $hooks_opt array that is passed to stream_context_create().

The headers required are:
X-NIM-API-USER
X-NIM-API-KEY

Here is an example of passing additional headers in the array. You'll need to replace $nim_username and $nim_api_key with a real user and their key.

Code: Select all

$hooks_opts = array('http' =>
                      array(
                          'method'  => 'GET',
                          'header'  => [   'X-NIM-API-USER: ' . $nim_username,
                                           'X-NIM-API-KEY: ' . $nim_api_key,
                                           'Content-type: application/x-www-form-urlencoded']
                      ),
                  'ssl' =>
                     array(
                        'verify_peer' => false,
                        'verify_peer_name' => false,
                        'allow_self_signed'=> true
                     )
                  );



Thanks,
Andrew

mitchell.lotierzo
Posts: 17
Joined: December 16th, 2016, 8:16 pm

Re: Custom Event Hooks

Postby mitchell.lotierzo » January 8th, 2018, 7:40 pm

Great thanks!

One more comment about the "onJobPostOnline" event hook. It would be more useful if this event fired after all the project folders were created. Currently, it's firing before any of the folders are created.

Thanks,
Mitch

andrew
Site Admin
Posts: 179
Joined: June 24th, 2014, 8:10 am

Re: Custom Event Hooks

Postby andrew » January 9th, 2018, 10:54 pm

We'll take a look at that. That was the original intention.

Thanks,
Andrew


Return to “API”

Who is online

Users browsing this forum: No registered users and 1 guest