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. 

Any input would be appreciated.

Thanks,
Steve
Hello Steve,

you may have stumbled upon a limitation of the native REST functionality. Haven't tested myself to confirm this...

In the meanwhile you might want to integrate "by hand", that is, do the requests yourself.

Take a look at these components in the OutSystems forge:

https://www.outsystems.com/forge/component/698/how-to-rest-made-easy/

https://www.outsystems.com/forge/component/422/restwebservices/
Solution
Hi Steve,

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


Solution
Had to edit my previous post, read the edit note at the end.
João Rosado wrote:
Hi Steve,

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.

Steve



 
Hi Steve,

You should read my reply better.
All the text and images after the "Currently you have an easy workaround" is explaining exactly what you need to do for that case.

(and don't forget to read the "Edit" note that explains that the images show OnResponse, but it should be OnRequest ...i just didn't retook the screenshots after noticing my mistake)

Regards,
João Rosado

Joäo,

can an you tell me what version of Service Studio you are using.  My version...9.0.1.25 does not give ne the option to set the OnRequest or OnRespnse attributes.

thanks,

steve
Hi Steve,

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

Regards,
João Rosado
Thanks João,

That certainly explains it.  Looks like I am going to be upgrading...

Steve