Granicus and Webhook Demo

Learn about building Web apps with ASP.NET Core.

How to Test Webhook Endpoints Using Postman

Follow these steps to send test requests to your webhook endpoints using Postman instead of curl.


1. Granicus Webhook Test

  1. Open Postman and create a new POST request.
  2. Set the URL to:
    https://localhost:7065/webhooks/granicus
  3. Under Headers, add:
    • Content-Typeapplication/json
  4. Under Body → select raw and paste this JSON:
    {
      "eventType": "NewMessage",
      "message": {
        "id": "12345"
      }
    }
  5. Click Send.

✅ You should see a 200 OK response, and the console should show:
Granicus Webhook received - Event: NewMessage, Message ID: 12345


2. SMS Opt-Out Webhook Test

Use this to simulate when a user unsubscribes from SMS messages.

Case A — Phone number doesn’t exist (example: 7025551234):
  1. Set the URL to:
    https://localhost:7065/webhooks/sms/optout
  2. Headers:
    • Content-Typeapplication/json
  3. Body → raw → JSON:
    {
      "completed_at": "2025-07-08T10:00:00Z",
      "message_type": "optout",
      "message_url": "https://example.com",
      "recipient_url": "https://recipient.com",
      "sid": "12345",
      "status": "success",
      "phone": "+17025551234"
    }
  4. Click Send.

Response example if phone not found:

{
  "message": "No student subscribed with this phone number."
}

Case B — Phone number exists (example: 7026140130):
  1. URL:
    https://localhost:7065/webhooks/sms/optout
  2. Headers and Body same as above, but replace the phone number:
  3. {
      "completed_at": "2025-07-08T10:00:00Z",
      "message_type": "optout",
      "message_url": "https://example.com",
      "recipient_url": "https://recipient.com",
      "sid": "12345",
      "status": "success",
      "phone": "+17026140130"
    }
  4. Click Send.

✅ Response if the phone exists and students were updated:

{
  "phone": "7026140130",
  "updatedStudents": 2,
  "eventType": "optout",
  "timestamp": "2025-07-08T10:00:00Z"
}

Notes:

  • You can also test on http://localhost:5254/... if using HTTP instead of HTTPS.
  • If testing locally, ensure your MVC app is running and listening on the same port.
  • For SSL warnings, enable “Disable SSL Verification” in Postman’s settings.

After sending the requests, open your ASP.NET MVC app’s console window — you should see confirmation messages for received webhooks and any database updates performed.