SendGrid WebHook REST API Problem

SendGrid WebHook REST API Problem

I am attempting to build a simple REST API (POST) for SendGrid's Event Webhook interface. The problem I am running into is with the JSON naming convention used in the SendGrid structure. They include a JSON name of "smtp-id". Notice the "dash" character. Here is an example:

{

"sg_message_id":"sendgrid_internal_message_id",

"email": "john.doe@sendgrid.com",

"timestamp": 1337197600,

"smtp-id": "<4FB4041F.6080505@sendgrid.com>",

"event": "delivered"

}

My problem is that when attempting to build a structure that maps to that JSON format, the system will not let me create an attribute with the name "smtp-id" because dashes are not allowed in names. That results in the system ignoring that name/value pair which is a big problem because that is the most important piece of information I need to map the SendGrid data to the internal eMail logging within Outsystems.

Has anyone run across this problem and if so do you have a solution? Or am is missing something really basic here? NOTE: I am running platform 9 and therefore the ardoJSON package is not compatible.

That should not be a limitation on the Consume REST API feature. All attributes/inputs/outputs inside REST API's have a "Original Name" property that allows dashes.

If you are trying to Expose a REST API, yes it is a current limitation that will be lifted on the next major version of the Platform.
Currently you have an easy workaround, just add a OnRequest callback and do a

Replace(CustomizedRequest.RequestText,"""smtp_id""","""smtp-id""")

and then call your attribute smtp_id

Note: also regarding the ardojson, you don't need it for this. But just for the record, there are versions of the component in the forge that are compatible with any platform version 7.0+.

Edit: just noticed that when i wrote this initially had incorrectly OnResponse instead of the OnRequest. Fixed the text, but my screenshots are still wrong. It's the same thing but just on the other callback and the replace the other way around "smtp_id" -> "smtp-id"

That should not be a limitation on the Consume REST API feature. All attributes/inputs/outputs inside REST API's have a "Original Name" property that allows dashes.

If you are trying to Expose a REST API, yes it is a current limitation that will be lifted on the next major version of the Platform.
Currently you have an easy workaround, just add a OnRequest callback and do a

Replace(CustomizedRequest.RequestText,"""smtp_id""","""smtp-id""")

and then call your attribute smtp_id

Note: also regarding the ardojson, you don't need it for this. But just for the record, there are versions of the component in the forge that are compatible with any platform version 7.0+.

Edit: just noticed that when i wrote this initially had incorrectly OnResponse instead of the OnRequest. Fixed the text, but my screenshots are still wrong. It's the same thing but just on the other callback and the replace the other way around "smtp_id" -> "smtp-id"

Regards,
João Rosado

João,

Thank you for your assistance. Actually SendGrid implements a Webhook interface. I must expose a REST API which they will POST a JSON document to after which I must process the JSON. Therefore, I am not creating a REST consumer but rather a exposing a REST API that must process the specific JSON document delivered within the body. Given the fact that I am exposing a REST API , I am not given the option of "original name" in my structure. Therefore, I assume that I will have to implement the ardoJSON extension within my solution...unless I am missing something.

Those extenbility features were added in 9.0.1.35 (Require both Platform Server and Development Environment 9.0.1.35+)
You can check the change log for that revision for more information:Platform Server 9.0.1.35