java - Managing JIRA webhooks via REST API -
i'm trying manage jira via java rest api. following questions: 1. how pass arguments in url via webhook while calling rest code. 2. how receive request passed via webhook in rest code.
i created webhook , called rest api in url provided http://localhost:8080/rest/jiraintegration/jiraservice/record
while rest code looks like
@path("/jiraservice") public class jiraservice { @get @path("/records") public string getjirarequest(inputstream response){ //req.getparameter("key"); bufferedreader br = null; stringbuilder sb = new stringbuilder(); string line; br = new bufferedreader(new inputstreamreader(response)); try { while ((line = br.readline()) != null) { sb.append(line); } } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } system.out.println("inputstream::"+sb.tostring()); return sb.tostring();
}
i'm new jira webhooks rest. kindly appreciated.
to receivie response webhook. need create webhook in jira , give url can access publicly. code should running on port 80 or 443.
now example link rest post call : http://xyz.abc.com/webservice/rest/jira/
in webhook should give url http://xyz.abc.com/webservice/rest/jira/
your rest controller have follwing rest method
@post() @consumes(mediatype.application_json) @produces(mediatype.application_json) public response postmsg(string h) {
gson gson = new gsonbuilder().setprettyprinting().create(); jsonparser jp = new jsonparser(); jsonelement je = jp.parse(h); string prettyjsonstring = gson.tojson(je); system.out.println("################################"); system.out.println(prettyjsonstring); string output = prettyjsonstring; return response.status(200).entity(output).build(); }
now after doing should configure webhook send respone on jira ticket created or updated etc.