Webservice response as chain input


(Ayush Mathur) #1

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 ?


(Ayush Mathur) #2

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 ?


(system) #3

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