asp.net mvc - How can I consume a Json Payload from a webhook and display certain features of the Json in vb.net MVC? -


i working on asp.net visual basic mvc application consume webhook has been fired jira when has been fired, display bits of information in application.

so far have got webhook fire , webhook url going requestb.in , send json payload (currently requestb.in) , can see working.

then using json has sent converted vb.net classes using paste json classes (this information want display):

public class jirawebhookobject    'properties  end class  public class issue   'properties  end class  public class fields 'properties end class  public class issuetype     'properties end class  public class priority     'properties end class  public class status     'properties end class  public class project     'properties end class  public class comment     'properties end class  public class comment1     'properties end class 

i created api controller connect class this: public class valuescontroller inherits apicontroller

'get api/values public function [get]() ienumerable(of string)     return new string() {"value1", "value2"} end function  'get api/values/5 public function [get](id integer) string     return "value" end function  'post api/values public sub post(<frombody> jirawebhookobject string)  end sub    end class 

but how display in application every json payload fired. trying deserialize data this:

request.inputstream.position = 0 request.inputstream.seek(0, seekorigin.begin) using reader = new streamreader(request.inputstream)           dim json = reader.readtoend()          dim contenttype string = request.contenttype          dim body = jsonconvert.deserializeobject(json)     try          select case directcast(body.key, string)              case ""                 'return json(success = true)              case else                 'return json(new {key .success = true, key .message = "some message"})              end select         catch ex exception     end try end using 

but in switch statement unsure of how display json in correct format. have use event display json data , how can done?

do need retrieve requestb.in url this:

    private shared sub test()          dim task = makerequestjira()         task.wait()          dim response = task.result         dim body = response.content.readasstringasync().result      end sub     private shared async function makerequestjira() task(of httpresponsemessage)        dim httpclient = new httpclient()        return await httpclient.getasync(new uri("http://requestb.in/x9xnl8w9"))     end function 

could have webhook url firing application (what url should specify) , use retrieve information?

this how got json payload webhook url:

function urlendpoint() actionresult          dim r system.io.streamreader = new system.io.streamreader(httpcontext.request.inputstream)         dim jsonas string = r.readtoend()         dim issue oject= jsonconvert.deserializeobject(of object)(json)         system.diagnostics.trace.traceerror(json) 

then create classes have correct information webhook:

public class object     public property issue issue     <datamember(name:="timestamp")>     public property timestamp long     public property comment comment3 end class 

then can want data after example display or send on via email


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -