Search code examples
c#jsontriggerscosm

COSM Trigger extracting JSON values using C# from an HTTP Post


Trying to receive COSM Trigger HTTP Post via a C# RESTful service, not receiving the alert. I took the COSM API JSON payload and used it from a test client - that worked. When I setup my feed and either try the debug trigger test, or just force the trigger to fire normally, my REST service doesn't get called. If I try any form of test client the service processes the JSON POST just fine.

C# service is here:

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "cosm", 
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    string CosmAlert(CosmTrigger data);

Where CosmTrigger is my class mirroring the COSM Trigger fields.

My COSM feed is here.

I'm starting from the COSM portal to fire a trigger, Twitter based trigger works fine, the HTTP Post to my URL isn't. How to debug this?


Solution

  • Tested and working code -

    [OperationContract]  
    [WebInvoke(Method = "POST",  
    BodyStyle = WebMessageBodyStyle.WrappedRequest,  
    UriTemplate = "cosm")]  
    string cosmStream(Stream body);