# Http task | Receive response as JSON and deliver it to the next task

**URL:** <https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743>\
**Category:** Flowable Engine\
**Created:** [July 20, 2017, 5:41pm UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743 "2017-07-20T17:41:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tilipro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/tilipro/32/249_2.png) [@tilipro](https://forum.flowable.org/u/tilipro)\
**Post date:** [July 20, 2017, 5:41pm UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/1 "2017-07-20T17:41:24Z")

</div>

Hi,

I´m trying to receive the response to a POST request in an http task. I was able to receive it but it comes as a string when it should be a JSON. Where should I define the response as a JSON?

After I get this JSON how can I send this response to the next task? Preferably if it can be in multiple parameters.

Thank you!!

---

<div class="post-metadata">

**Author:** ![h7kanna](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/h7kanna/32/104_2.png) [@h7kanna](https://forum.flowable.org/u/h7kanna)\
**Post date:** [July 20, 2017, 6:56pm UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/2 "2017-07-20T18:56:29Z")

</div>

Hi @tilipro,

Does the server depends on request headers Accept : application/json ?

Thanks,  
Harsha

---

<div class="post-metadata">

**Author:** ![tilipro](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/tilipro/32/249_2.png) [@tilipro](https://forum.flowable.org/u/tilipro)\
**Post date:** [July 20, 2017, 7:11pm UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/3 "2017-07-20T19:11:25Z")

</div>

Thanks for the answer but that didn´t solve the issue. I re-read the documentation and found that the String variable type can also be used as JSON I think.

The problem now is that I want to use the JSON I received on another Http task post. I added the variable as ${varName} in the request body and in the request header I put Content-Type: application/json  
But this doesn´t works and the stacktrace isn´t very well explained. Can you figure out how to solve this?

```
04:10:30,409 [http-nio-8080-exec-86] INFO org.flowable.http.impl.HttpActivityBehaviorImpl - HTTP client is initialized
04:10:30,412 [http-nio-8080-exec-86] INFO org.flowable.http.impl.HttpActivityBehaviorImpl - HTTP client is initialized
04:10:30,492 [http-nio-8080-exec-86] INFO org.flowable.engine.impl.app.AppDeployer - Processing app resource testApp.app
04:10:35,426 [http-nio-8080-exec-93] ERROR org.flowable.rest.exception.BaseExceptionHandlerAdvice - Unhandled exception
org.flowable.engine.common.api.FlowableException: HTTP exception occurred
	at org.flowable.http.impl.HttpActivityBehaviorImpl.perform(HttpActivityBehaviorImpl.java:220)
	at org.flowable.http.HttpActivityBehavior.execute(HttpActivityBehavior.java:137)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:231)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:152)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:109)
	at org.flowable.engine.impl.agenda.DebugContinueProcessOperation.continueThroughFlowNode(DebugContinueProcessOperation.java:50)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughSequenceFlow(ContinueProcessOperation.java:277)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:75)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:81)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:65)
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:49)
	at org.flowable.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:51)
	at org.flowable.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
	at org.flowable.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
	at org.flowable.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
	at org.flowable.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
	at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
	at org.flowable.engine.impl.RuntimeServiceImpl.startProcessInstanceWithForm(RuntimeServiceImpl.java:138)
	at org.flowable.app.service.runtime.FlowableProcessInstanceService.startNewProcessInstance(FlowableProcessInstanceService.java:126)
	at org.flowable.app.service.runtime.FlowableProcessInstanceService$$FastClassBySpringCGLIB$$c8366971.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
	at org.flowable.app.service.runtime.FlowableProcessInstanceService$$EnhancerBySpringCGLIB$$e0d91202.startNewProcessInstance(<generated>)
	at org.flowable.app.rest.runtime.ProcessInstancesResource.startNewProcessInstance(ProcessInstancesResource.java:32)
	at sun.reflect.GeneratedMethodAccessor1784.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.flowable.app.filter.FlowableCookieFilter.doFilterInternal(FlowableCookieFilter.java:154)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.client.ClientProtocolException
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	at org.flowable.http.impl.HttpActivityBehaviorImpl.perform(HttpActivityBehaviorImpl.java:190)
	... 101 more
Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:149)
	at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
	at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
	at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
	at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)
	at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
	at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	... 104 more
```

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [July 23, 2017, 8:17am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/4 "2017-07-23T08:17:13Z")

</div>

> [@tilipro](#):
>
> Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response

The error isn’t very helpful … can you see what goes over the actual wire or what’s received on the server side?

---

<div class="post-metadata">

**Author:** ![Imran\_Ahmed](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/imran_ahmed/32/324_2.png) [@Imran\_Ahmed](https://forum.flowable.org/u/Imran_Ahmed)\
**Post date:** [October 4, 2017, 4:23am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/5 "2017-10-04T04:23:30Z")

</div>

Hi Harsha,

I have created a process with rest task and user task. For the rest task i gave Request Method : GET, Request URL.

It does execute REST task successfully and went to next task.

But i dont see any results returned from REST task. so is there a way to see JSON results returned in modeler itself ?

Any help appreciated.

---

<div class="post-metadata">

**Author:** ![hari.shan89](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@hari.shan89](https://forum.flowable.org/u/hari.shan89)\
**Post date:** [July 25, 2018, 9:51am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/6 "2018-07-25T09:51:11Z")

</div>

> [@Imran\_Ahmed](#):
>
> It does execute REST task successfully and went to next task

Hi Team,

Can you please guide me how to execute or initiate Http task using java

Regards,  
!-!@ri

---

<div class="post-metadata">

**Author:** ![hari.shan89](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@hari.shan89](https://forum.flowable.org/u/hari.shan89)\
**Post date:** [July 25, 2018, 9:51am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/7 "2018-07-25T09:51:43Z")

</div>

> [@hari.shan89](#):
>
> Hi Team,
> 
> Can you please guide me how to execute or initiate Http task using java
> 
> Regards,  
> !-!@ri

Hi Team,

Can you please guide me how to execute or initiate Http task

Regards,  
!-!@ri

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [July 25, 2018, 10:49am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/8 "2018-07-25T10:49:32Z")

</div>

@Imran_Ahmed

> But i dont see any results returned from REST task. so is there a way to see JSON results returned in modeler itself ?

You can’t see this int he modeler itself. This is part of the runtime execution. Have a look at the [Http Task](https://www.flowable.org/docs/userguide/index.html#bpmnHttpTask) section of the Flowable documentation to see how response and the variables can be saved.

@hari.shan89 why do you want to initiate the Http task manually? If you want to call an external service through REST with Java API there are multiple other frameworks that you can use.

---

<div class="post-metadata">

**Author:** ![hari.shan89](https://avatars.discourse-cdn.com/v4/letter/h/ecccb3/32.png) [@hari.shan89](https://forum.flowable.org/u/hari.shan89)\
**Post date:** [July 25, 2018, 11:17am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/9 "2018-07-25T11:17:54Z")

</div>

Hi filiphr,

Thanks for your response,i need to implement a workflow to call restAPI service through flowable task (HTTP) for async execution , i need to call the process instance created using service task (HTTP) .

Regards,  
Hari

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [July 26, 2018, 8:42am UTC](https://forum.flowable.org/t/http-task-receive-response-as-json-and-deliver-it-to-the-next-task/743/10 "2018-07-26T08:42:08Z")

</div>

Hey Hari,

Why would you want to manually execute the async task? You know that Flowable has an async job handler that fetches those jobs and executes them.

Having said that, there is a way to manually execute an async job. This can be done through the [`ManagementService`](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/ManagementService.java). You will first need to find the job through the `createJobQuery` or if the job is suspended through `createSuspendedJobQuery`.

Hope this helps.

Cheers,  
Filip
