Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Amine Amine
Web service rest
October 3, 2012 7:31 AM

Amine Amine

Rank: New Member

Posts: 21

Join Date: May 27, 2012

Recent Posts

Hello every body,

I'm using jira rest web service from liferay, but when I execute code for web service then i refresh jira pages I got disconnected from liferay
I wish that you can help me

this is the code for calling the rest web service

public void reportToBugTracker(String summary, String description,
String type, String priorityId, String dueDate,
String componentsId) {
try {

Properties prop = new Properties();


String serverURL = prop.getProperty("ServerURL");
String login = prop.getProperty("Login");
String password = prop.getProperty("Password");
String projectKey = prop.getProperty("ProjectKey");
System.out.println("exxxxxxxee"+serverURL+" "+login+" "+password+" "+projectKey);

String auth = new String(Base64.encode(login + ":" + password));
System.out.println(serverURL+" "+login+" "+password+" "+projectKey);

JSONObject data = new JSONObject();
JSONObject fields = new JSONObject();
JSONObject project = new JSONObject();
JSONObject issuetype = new JSONObject();
JSONObject priority = new JSONObject();
JSONObject components = new JSONObject();
project.put("key", projectKey);
fields.put("project", project);
fields.put("summary", summary);
issuetype.put("name", type);
fields.put("issuetype", issuetype);
priority.put("id", priorityId);
fields.put("priority", priority);
fields.put("description", description);
fields.put("duedate", dueDate);
components.put("id", componentsId);
fields.append("components", components);
data.put("fields", fields);

connectWithBugsTracker(serverURL + "/rest/api/2/issue",auth, data.toString());

} catch (AuthenticationException e) {
// TODO Auto-generated catch block
} catch (ClientHandlerException e) {
// TODO Auto-generated catch block
} catch (JSONException e) {
// TODO Auto-generated catch block
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block


* Cette methode assure la connexion au serveur de gestion d'anomalies et
* assure le traitement des requétes evoyées
* @param serverURL
* Url du serveur de gestion d'anomalie
* @param auth
* Login et mot de passe
* @param data
* les données de la requete
* @return String réponse de la requéte
* */
private static String connectWithBugsTracker(String serverURL, String auth,
String data) throws AuthenticationException, ClientHandlerException {
Client client = Client.create();
WebResource webResource = client.resource(serverURL);

ClientResponse response = webResource
.header("Authorization", "Basic " + auth)
.header("Keep-Alive", "true").
.post(ClientResponse.class, data);

int statusCode = response.getStatus();
if (statusCode == 401) {
throw new AuthenticationException("Invalid Username or Password");

return response.getEntity(String.class);

thank you emoticon
Traolly Xiong
RE: Web service rest
March 6, 2013 9:56 PM

Traolly Xiong

Rank: Regular Member

Posts: 173

Join Date: December 30, 2011

Recent Posts

Hello ,
Did you have any luck creating the client from LR and making SOAP APIs calls to JIRA?
If yes, any good tips on getting started would fully appreciated.