79079275

Date: 2024-10-11 17:56:52
Score: 0.5
Natty:
Report link

The problem is less inside json_set, as I assumed in the question, it is more in the conjunction with http_post() from pgsql-http. If I cast the jsonb object to text and change that http_post() call to this:

CREATE OR REPLACE FUNCTION public.webhook()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
    BEGIN
        PERFORM status FROM 
        http_post('https://automate.nrkt.enerkite.com/webhook-test/redmine', 
            jsonb_build_object( 'action',TG_OP,
                                'table',TG_TABLE_NAME,
                                'value',to_jsonb(NEW.*))::text,
                                'application/json');
        RETURN NULL;
    END;
$function$
;

it works. Thank You all for helping. Zegarek, you pointed me in the right direction by You debug mechanism, which showed, taht my problem was not where I thought.

Reasons:
  • Blacklisted phrase (0.5): Thank You
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Ruebe