How to call POST method with request on APOC Trigger

My APOC Function

CALL apoc.trigger.add('updateTrigger',
        'UNWIND keys($assignedNodeProperties) as k
        UNWIND $assignedNodeProperties[k] AS prop
        with prop.node AS node, prop.key AS key, prop.old AS oldValue, prop.new AS newValue
        with {
        key:key,
        oldValue:oldValue,
        newValue:newValue,
        elementId:elementId(node),
        createdDateTime:timestamp()} as requestBody

         CALL apoc.load.jsonParams("https://us-central1-kampl-fcid.cloudfunctions.net/SLI/api/slidt-apoc", 
         {method: "POST"},
        apoc.convert.toJson(requestBody)
        ) yield value return value
', {phase:'before'});`

whenever i will update my property it should call POST API request
In this requestBody i want to pass all values.

My APOC Trigger Works but when i pass my requestBody to the apoc.convert.toJson(body) method

i got my requestBody map like
{"{key:"surname",oldValue:"Smith",newValue:"Burgman"}":""}}

I don't know why my requestBody became key in this scenario
is there any syntax error
please let me know.

I want to achieve this on my cloud function
{key:"surname",oldValue:"Smith",newValue:"Burgman"}

I print this bodyRequest on my firebase cloud function console using below method

app.post("/api/slidt-apoc", (req, res) => {

let body = req.body;
let data=JSON.stringify(body)
console.log("Request Data "+data);
}

I got above result

Please help

That's really unexpected. Perhaps you need to add content-type application/json to the request and to the server too. Not that the server just used x-url-encode-form-data by default?

it should just work, like this :return apoc.convert.toJson({a:42})

can you please open a GH issue

1 Like