Mehul
Mehul

Reputation: 178

In Marklogic, I have a custom JavaScript function. How do I call it through REST API? What is the process of calling it from CURL?

I have a few documents in my database and I've designed search functions for them. So I want to use curl in cmd and call the function so that I can run the searches and print the results in cmd only.

For example, I have a function where I'm passing the "userID" and I want all relevant documents. So I need to pass that value in the code or can I specify this(params) in curl.

If not curl, what other REST API options do we have to call custom JavaScript functions?

Upvotes: 0

Views: 117

Answers (1)

ehennum
ehennum

Reputation: 7335

One approach is to create a REST API server and use either the invoke or resource service extension endpoints to invoke your script.

For information about standing up the REST API, see:

http://docs.marklogic.com/guide/rest-dev/intro#id_97899

For information about invoking code, see:

http://docs.marklogic.com/guide/rest-dev/extensions#id_72813

For information about a resource service extension (which requires that your code conform to conventions), see:

http://docs.marklogic.com/guide/rest-dev/extensions#id_21018

Hoping that helps,

Upvotes: 1

Related Questions