Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we post messages to event grid topics?

I have created event grid topic in azure using event schema = "Event Grid Schema".

The next steps for me is trying to send messages to that event grid topic so the subscribers can do something when the message has been successfully received in event grid topic.

However, I had a problem when sending the message to event grid topic. It always reject my JSON request with error "Required property 'subject' was not set. even tough, I have explicitly set the subject in my JSON post body.

I have also add 'aeg-sas-key' value in header for authentication purposes.

Here is an example of my JSON format:

{
    "id": "19291",
    "subject": "myapp/vehicles/motorcycles",
    "topic": "VehicleData",
    "eventType": "statusupdated",
    "eventTime": "2019-05-12T18:41:00.9584103Z",
    "data":{
         "firstName": "Jason",
         "postalAddress": "xyz"
    },
    "dataVersion": "1.0",
    "metadataVersion": "string"
  }

and Here is the output:

{
    "error": {
        "code": "BadRequest",
        "message": "Required property 'subject' was not set. Report '433759ee-6570-466e-ae12-a6dc5fccbfe1:5/14/2019 4:01:32 AM (UTC)' to our forums for assistance or raise a support ticket.",
        "details": [
            {
                "code": "InputJsonInvalid",
                "message": "Required property 'subject' was not set. Report '433759ee-6570-466e-ae12-a6dc5fccbfe1:5/14/2019 4:01:32 AM (UTC)' to our forums for assistance or raise a support ticket."
            }
        ]
    }
}

Any idea why it always ask for subject even tough I have provided the subject in my JSON?

like image 522
Arif Liminto Avatar asked Dec 04 '25 16:12

Arif Liminto


1 Answers

Based on the docs:

Post to custom topic for Azure Event Grid

Azure Event Grid event schema

use the following payload:

    [
      {
        "id": "19291",
        "subject": "myapp/vehicles/motorcycles",
        "topic": null,
        "eventType": "statusupdated",
        "eventTime": "2019-05-12T18:41:00.9584103Z",
        "data": {
          "firstName": "Jason",
          "postalAddress": "xyz"
          },
        "dataVersion": "1.0",
        "metadataVersion": null
      }
   ]
like image 162
Roman Kiss Avatar answered Dec 06 '25 07:12

Roman Kiss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!