Splunk Dev

Invoking Custom Endpoint from Javascript- Receiving error - {"messages":[{"type":"ERROR","text":"JSON reply had no \"pay

sdawood
Engager

Hi all,

I am trying to call custom endpoint from dashboard JavaScript file on user interaction (This is a setup page).

python_code.py

 

 

class TestAndSaveOrUpdateCredentials(PersistentServerConnectionApplication):
    def __init__(self, command_line, command_arg):
        super(PersistentServerConnectionApplication, self).__init__()

    def handle(self, in_string):
        return {
         "payload":in_string,
         "status": 200
        }

 

 

restmap.conf

 

 

[script:test_endpoint]
match = /testing-123
script = python_code.py
scripttype = persist
handler = python_code.TestAndSaveOrUpdateCredentials
passHttpHeaders = true
output_modes = json
passHttpCookies = true

 

 

web.conf

 

 

[expose:test_endpoint]
methods = GET, POST
pattern = testing-123

 

 

JavaScript

 

 

const appNamespace = {
    owner: "", # Tried with admin,nobady
    app: "", # Tried with app_name
    sharing: "global", # tried with 'app'
}
const http = new splunkjs.SplunkWebHttp();
const service = new splunkjs.Service(
        http,
        appNamespace,
    );
service.get("testing-123")
//service.get("services/testing-123")

 

 

 

 

I am able to call localhost:8089/services/testing-123 from postman, but from JavaScript seeing this error

 

 

{"messages":[{"type":"ERROR","text":"JSON reply had no \"payload\" value"}]}

 

 

 

Please let me know where I am doing wrong

Thanks.

Labels (3)
Tags (1)

jbrocks
Communicator

Hi, did you found a solution?

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...