'Trigger jenkins job and receive JSON like response

I would like to trigger a Jenkins job using something like curl, and receive a response from this job a JSON format (or any other).

In other words, I would like to create a small single endpoint API using a Jenkins job.

Is this possible ?

https://my-jenkins/api/trigger-job => process.. => HTTP Response with JSON {"some_content": "content"}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source