Create a REST API to call flowable

I need to create an application (may be a REST api) such that i can create a task from the code, that task should be reflected in flowable UI .
At this point I am trying to make flowable-rest and flowable-task pointing to same mysql database as they both have different h2 databases as tasks i create in flowable-rest(localhost:8080/flowable-rest/service/runtime/tasks ) is not visible on flowable UI(http://localhost:8080/flowable-task/workflow/#/tasks) .So i am stuck at this. My next step would be to create a REST api to create flowable tasks and get that reflected on UI.
Can I do this by calling flowable-rest in my REST api or any other way?
I need a sample code for the same
It would be really helpful if someone could guide.

Thanks in advance

What config do you have for the task app and the rest app? Are you pointing them to the same db?
Once you have that, the result of calling the rest api will be shown in the task UI.

Hi Shweta,

may be this is too late reply for you, but for the sake of forum adding the solution,

public static final String processDefinitions = “http://localhost:8080/flowable-rest/service/repository/process-definitions”;

public CloseableHttpResponse getHttpResponse(String url)
{

	String userName = "kermit";
	String userPassword = "kermit";
    HttpGet httpget = new HttpGet(url);

    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, 
        new UsernamePasswordCredentials(userName,userPassword));
    
    CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
    
    CloseableHttpResponse response =null;
	try {
		
		response = httpClient.execute(httpget);
		
	} catch (ClientProtocolException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    return response;
}


public HashMap<String, String> getProcessDefinitions(String requestQuery)
{
	HashMap<String, String> mapProcessDefs = null;
	try {
        
        ObjectMapper objectMapper = new ObjectMapper();

        CloseableHttpResponse response =getHttpResponse(requestQuery);
        
        //System.out.println("Response2 : "+response.getStatusLine().getStatusCode());

        JsonNode jsonNode = objectMapper.readTree(IOUtils.toString(response.getEntity().getContent(), "UTF-8"));
        
        mapProcessDefs = new ResponseJSONRetriever(jsonNode).getProcessDefinitions("data");
        
        //System.out.println("mapProcessDefs Size : "+mapProcessDefs.size()+"--"+mapProcessDefs.toString());
        response.close();

        return mapProcessDefs;
        
    } catch (Exception e) {
        e.printStackTrace();
    }
	return mapProcessDefs;
}

public static void main(String[] args) {

	GetUserCurrentStages getUserCurrentStages = new GetUserCurrentStages();
	
    System.out.println(" Process Definitions : "+ getUserCurrentStages.getProcessDefinitions(processDefinitions) );

}

public static HashMap<String, String> getProcessDefinitions(String valueList) throws JsonMappingException,JsonGenerationException,IOException
{
HashMap<String, String> mapProcessDefs = new HashMap<String, String>();

	JsonNode contactNode = root.path(valueList);
	
	if (contactNode.isArray()) {
		// If this node an Arrray?
		System.out.println("isArray Size :"+contactNode.size());
		for (JsonNode itemNode : (ArrayNode) contactNode) {
			String id = itemNode.path("id").asText();
			String name = itemNode.path("name").asText();
			System.out.println(name + " --> " + id);
			//System.out.println("name : " + ref);
			mapProcessDefs.put(id, name);
        }
	}else
	{
		System.out.println("Its Array List Size : "+contactNode.size());
		for (JsonNode itemNode : contactNode) {
			String id = itemNode.path("id").asText();
			String name = itemNode.path("name").asText();
			System.out.println(name + " --> " + id);
			//System.out.println("name : " + ref);
			mapProcessDefs.put(id, name);
		}
	}
	
	return mapProcessDefs;
}

Thanks,
Vzy