# Webservice response as chain input

**URL:** <https://discuss.elastic.co/t/webservice-response-as-chain-input/119837>\
**Category:** Elasticsearch\
**Created:** [February 14, 2018, 3:54pm UTC](https://discuss.elastic.co/t/webservice-response-as-chain-input/119837 "2018-02-14T15:54:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayush\_Mathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayush_mathur/32/77134_2.png) [@Ayush\_Mathur](https://discuss.elastic.co/u/Ayush_Mathur)\
**Post date:** [February 14, 2018, 3:54pm UTC](https://discuss.elastic.co/t/webservice-response-as-chain-input/119837/1 "2018-02-14T15:54:43Z")

</div>

Hi,  
I'm querying an external web service from which I receive a response in JSON format. I'm then trying to chain this output to another query and specifying the path of payload as "path".  
However, no matter if I use {{ctx.first.payload}} or {{ctx.chain.first.payload}}, etc. I'm always getting this error response:

{  
"error": {  
"root\_cause": [  
{  
"type": "parse\_exception",  
"reason": "could not parse input for watch [my\_watch]. expected an object representing input [path], but found [VALUE\_STRING] instead"  
}  
],  
"type": "parse\_exception",  
"reason": "could not parse input for watch [my\_watch]. expected an object representing input [path], but found [VALUE\_STRING] instead"  
},  
"status": 400  
}

Is it possible to somehow get the output of web service response in 1st input http request and use it as input for second input (which uses aggregation on first's output) ?  
Also, is there a way to change the format of {{ctx.trigger.triggered\_time}} while using in http input request ?

---

<div class="post-metadata">

**Author:** ![Ayush\_Mathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayush_mathur/32/77134_2.png) [@Ayush\_Mathur](https://discuss.elastic.co/u/Ayush_Mathur)\
**Post date:** [February 16, 2018, 4:48pm UTC](https://discuss.elastic.co/t/webservice-response-as-chain-input/119837/2 "2018-02-16T16:48:23Z")

</div>

Update:  
I am now able to access the http json response as chain input, however, while doing so, I can see some additional keys are being generated for each object inside the array.  
Actual HTTP Response:

```
"Array": [{
	"Origin": "System"
	"Status": "Open",
	"Version": "1.0"
},
{
	"Origin": "Service"
	"Status": "In Progress",
	"Version": "1.5"
},
{
	"Origin": "System"
	"Status": "Closed",
	"Version": "2.0"
}]

```

However, when the response is chained as input for next query, this is what the payload looks like:

```
"Array": [{
	0={
	"Origin": "System"
	"Status": "Open",
	"Version": "1.0"
	},
	1={
		"Origin": "System"
		"Status": "Closed",
		"Version": "2.0"
	},
	2={
		"Origin": "Service"
		"Status": "In Progress",
		"Version": "1.5"
	}
}]

```

As a result, when I try to parse the payload for match filter criteria, I get the following exception: ParsingException[Unknown key for a START\_OBJECT in [script].]

Any idea what could be going wrong here and how it can be resolved ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 16, 2018, 4:48pm UTC](https://discuss.elastic.co/t/webservice-response-as-chain-input/119837/3 "2018-03-16T16:48:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
