Jean-Guy:
Partly a guess here, but the trigger has already fetched the pre and/or post verion(s) of the affected row, so it is no longer available to the URL that you wrote. I would suggest just having the SPL version convert the pre or post or both records, as appropriate, to ROW() types then use genbson()::JSON to perform the conversion directly there. Writing a generic function would be harder in SPL, but you don't have to each SPL trigger function can be specific to the trigger that calls it anyway.
Art