Eventing - post a new function

What are the required parameters in POST body for adding an eventing function to Couchbase?

I am referencing this api call in documentation.
https://docs.couchbase.com/server/current/eventing/eventing-api.html# - POST /api/v1/functions/[function_name]

Would be nice to have an example for every eventing api call in the docs.

This the error I am getting from the eventing node:
“name”: “ERR_INVALID_CONFIG”,
“code”: 38,
“description”: “Invalid configuration”,
“attributes”: null,
“runtime_info”: {
“code”: 38,
“info”: “Function name should not be empty”
}

Hi @Michal_Dolnak,

Thanks for your feedback. I’ve created task DOC-7809 and we will add samples for each REST API endpoint.

Regarding contents, we are indeed in the process of specifying this precisely using a JSON schema, but this will ship only in 7.0 of the product (and so it’s not of immediate help to you). Please see MB-41236 - the schema in 7.0 can be seen in these files:

Schema for handler
Schema for bindings of handler
Schema for settings of handler
Schema for a list of handlers

However, as 7.0 is not yet released, in older versions of the product, my suggestion would be to create a small handler from the Couchbase UI and read the object out using GET /api/v1/functions/fn_name then modify the resulting object and write it back using POST to the same location. This way, all necessary fields will be prefilled.

Finally, the function name appearing on the URL of POST to /api/v1/functions/fn_name, and the function name appearing in the body of the POST message must match, failing which you’d get the error message seen.

If you encounter any problems, don’t hesitate to ping us here on forums.

Best Regards,
Siri

Thanks @Siri for your reply.

I can confirm this works for Couchbase 6.6:
Read the object out using GET /api/v1/functions/fn_name then modify the resulting object and write it back using POST to the same location. This way, all necessary fields will be prefilled.