Is there any way we can send JSON data when we use POST API call to trigger Azure webjob?

2025-05-13T12:07:15.5733333+00:00

I have a webjob that needs to run when we call the Azure webjob webhook URL, which works fine, and I am successfully able to do a POST call in the Postman application using the given URL and credentials, which we can see when we click the webjob name. So the question is, can we send JSON data in the post call, and can we be able to fetch it inside the webjob? I used PHP to build the web job, and I checked the $_SERVER variable but was not able to find the JSON data that I sent in the call. I'm completely new to API, and please, anyone, give me advice.

Thanks,

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Michele Ariis 2,040 Reputation points MVP
    2025-05-13T12:43:49.4666667+00:00

    Hi, the Kudu WebJobs API doesn’t forward the POST body to your job. The only data you can send is a single arguments string, either in the query-string or as a JSON property named arguments:

    curl -u user:pwd \
      -H "Content-Type: application/json" \
      -d '{"arguments":"{\"orderId\":123,\"action\":\"ship\"}"}' \
      https://<site>.scm.azurewebsites.net/api/triggeredwebjobs/<job>/run
    

    At run-time that string is exposed to the job as:

    the environment variable WEBJOBS_COMMAND_ARGUMENTS, and

    the first command-line argument ($argv[1]) for console apps.

    So—wrap your JSON inside the arguments string and parse it in your PHP code:

    $payload = json_decode(getenv('WEBJOBS_COMMAND_ARGUMENTS') ?: $argv[1], true);
    
    1 person found this answer helpful.
    0 comments No comments

  2. Michele Ariis 2,040 Reputation points MVP
    2025-05-14T06:05:32.1566667+00:00

    /run only looks at the arguments query-string; the POST body is simply ignored, so the JSON trick will never fire the job.

    POST .../triggeredwebjobs/<job>/run?arguments=%7B%22name%22%3A%22John%22%2C%22age%22%3A98%7D
    

    That string turns up inside the job as WEBJOBS_COMMAND_ARGUMENTS (or argv[1]). The Kudu API spec shows the arguments parameter defined in=query, not in the body.

    Is the query-string safe?

    -The call is over HTTPS and you authenticate with the site-level credentials, so the data is encrypted in transit.

    -It will appear in App Service access logs; if that bothers you, Base64-encode or encrypt the JSON before sending and decode inside the job.

    If you really need a POST body, wrap the WebJob with your own API (Function/App Service) that accepts a JSON payload, then triggers the job internally – the native WebJob endpoint can’t do it.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.