Building for the Splunk Platform

Call to custom/eai endpoint from setup view

breid1313
Path Finder

Hello all - 

I'm creating a setup view (migrating from setup.xml) for an app and would like to continue to leverage the custom eai python handler that is already in place.

Can anyone point me towards an example of this? I may be using web.conf incorrectly as I can access the handler via port 8089 but when I attempt to call the endpoint from the setup view via the splunkjs sdk it generates a 404 error.

Once I resolve this issue I believe I should be able to pass all the parameters necessary into data: {TODO} in order to use the eai handler the same way we were when using setup.xml

 

app.js

 

 

 

    callScript(){
      $.ajax({
            type: "POST",
            url: "/servicesNS/-/<app_name>/configureMyApp/handleConfig",
            data: {TODO},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                console.log("success returned");
                console.log(data);
            },
            error: function(xhr){
     console.log("Error ", xhr);
         }
      });
    }

 

 

 

 

restmap.conf

 

 

[admin:configureMyApp]
match                 = /configureMyApp
members               = handleConfig        

[admin_external:handleConfig]
handlertype           = python
python.version        = python3
handlerfile           = handler.py
handleractions        = list, edit
handlerpersistentmode = false

 

 

 

web.conf

 

 

[expose:configureMyApp]
methods = GET, POST
pattern = configureMyApp

[expose:handleConfig]
pattern = configureMyApp/*
methods = GET, POST

 

 

Labels (4)
0 Karma

breid1313
Path Finder

My goals could also be accomplished with a [script:] stanza as well. Since we are using a setup view now, all the configuration is done with the splunkjs SDK before the python script is called, so I don't necessarily need an eai endpoint. All I'm looking to do is test a connection to a third-party app using a custom endpoint.

Same question applies here though. I've messed with the examples but get 404's through the js sdk using both a [script:] and [admin:]/[admin_external:] endpoint.

0 Karma
Get Updates on the Splunk Community!

Data Preparation Made Easy: SPL2 for Edge Processor

By now, you may have heard the exciting news that Edge Processor, the easy-to-use Splunk data preparation tool ...

Introducing Edge Processor: Next Gen Data Transformation

We get it - not only can it take a lot of time, money and resources to get data into Splunk, but it also takes ...

Tips & Tricks When Using Ingest Actions

Tune in to learn about:Large scale architecture when using Ingest ActionsRegEx performance considerations ...