How To Pass Basic Auth In Eventing Curl Request At Eventing

Hi,

How can I add basic auth in eventing curl request

function OnUpdate(doc, meta) {
    
    try
    {
        doc.id=doc.productId
    
    var response=
    curl("elasticip:port/products/_doc/"+doc.id,{method:"POST",data:doc})
    
    log("Doc created/updated", doc.productId);    
    }
    catch (e) {
        log("cURL products request had an exception:",e)
    }

}

Thanks.

You need to setup the URL as a “binding” in the function and then reference that from the curl call: cURL | Couchbase Docs. This is a bit of forced security to segregate credentials from the code and only allow pre-defined endpoints being called.

And for Capella specifically: Manage Eventing Functions and Settings | Couchbase Docs.

I dont see binding in eventing edit because of I never scroll down :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.