Display data from Json response

(Chris Kyriacou) #1

Hi,

I’ve set up a webhook and am trying to display values from the response but I cant figure out how to do it.

Here is a sample response:
{
“success”: true, “response”: {
“message”: “Successfully saved Lead”, “data”: {
“id”: “afa4c632-75af-43c2-a357-4aa26e1bfc50”, “company_id”: “926438f4-9e06-4385-a280-83440aea9a6d”, “status_id”: 1,
“first_name”: “Tom”,
“last_name”: “Hughes”,
“telephone”: “01111 111111”,
“email”: "tom@email.io",
“house_number”: “9”,
“street”: “ANY AVENUE”,
“postcode”: “DN44 9RA”,
“form_id”: “b8b5291b-bbed-4bab-ba48-749680317d9e”, “extras”: {
“address_line_two”: null, “town”: null,
ea9a6d",
“city”: “GRIMSBY”,
“county”: “NORTH EAST LINCOLNSHIRE”, “property_type”: 2,
“bedrooms”: 3,
“bathrooms”: 1,
“comment”: “API REQUEST”,
“original_company”: "926438f4-9e06-4385-a280-83440a
“utm_source”: null, “referer”: null, “referer_id”: null, “generated_email_fired”: true
},
“updated_at”: “2017-04-03 15:02:53”, “created_at”: “2017-04-03 15:02:50”, “status”: {
“id”: 1,
“name”: “New”,
“description”: “Lead has not yet been contacted”
}, “valuation”: {
“id”: “7a0f3fa4-f28e-46eb-8000-38cb63717f29”, “sales_min”: 50000,
“sales_max”: 100000,
“sales_average”: 75000,
“lettings_min”: 500,
“lettings_max”: 1000,
“lettings_average”: 750,
“lead_id”: “afa4c632-75af-43c2-a357-4aa26e1bfc50”, “created_at”: “2017-04-03 15:02:51”,
“updated_at”: “2017-04-03 15:02:51” }
} }
}

I want to display the result from ‘sales_average’ can you tell me how to do it please?

Regards
Chris

(John Jackson) #2

This is easier to read if you beautify the result:

{
	"success": true,
	"response": {
		"message": "Successfully saved Lead",
		"data": {
			"id": "afa4c632-75af-43c2-a357-4aa26e1bfc50",
			"company_id": "926438f4-9e06-4385-a280-83440aea9a6d",
			"status_id": 1,
			"first_name": "Tom",
			"last_name": "Hughes",
			"telephone": "01111 111111",
			"email": "tom@email.io",
			"house_number": "9",
			"street": "ANY AVENUE",
			"postcode": "DN44 9RA",
			"form_id": "b8b5291b-bbed-4bab-ba48-749680317d9e",
			"extras": {
				"address_line_two": "null",
				"town": "null",
				"city": "GRIMSBY",
				"county": "NORTH EAST LINCOLNSHIRE",
				"property_type": 2,
				"bedrooms": 3,
				"bathrooms": 1,
				"comment": "API REQUEST",
				"original_company": "926438f4-9e06-4385-a280-83440a",
				"utm_source": "",
				"referer": "null",
				"referer_id": "null",
				"generated_email_fired": true
			},
			"updated_at": "2017-04-03 15:02:53",
			"created_at": "2017-04-03 15:02:50",
			"status": {
				"id": 1,
				"name": "New",
				"description": "Lead has not yet been contacted"
			},
			"valuation": {
				"id": "7a0f3fa4-f28e-46eb-8000-38cb63717f29",
				"sales_min": 50000,
				"sales_max": 100000,
				"sales_average": 75000,
				"lettings_min": 500,
				"lettings_max": 1000,
				"lettings_average": 750,
				"lead_id": "afa4c632-75af-43c2-a357-4aa26e1bfc50",
				"created_at": "2017-04-03 15:02:51",
				"updated_at": "2017-04-03 15:02:51"
			}
		}
	}
}

I think the value is in result__response__data__valuation__sales_average (where result is the output name`).

(Chris Kyriacou) #3

Thanks John!

Unfortunately I’m not in control of the response, it belongs to a third party.

I still can’t get this to work :frowning:, this is what I’ve done:

I have a Make a HTTP Request module with the webhook URL in it. I have set it to JSON content type and ticked the box to enable JSON nesting. The next module “Send a Message” - response path= "respond to webhook. What exactly should I type in the message box?

(John Jackson) #4

In the message box, type {{ (you should see the ‘output selector’. Then choose the ‘Data’ output from the HTTP Request, then type:

response__data__valuation__sales_average

This is the ‘key’. You should then see something like this:

{{some_task_name.data__response__data__valuation__sales_average}}

Hope that makes sense. This should just pick out the key that you need (data is the output and the rest points to the item within the data).

(Chris Kyriacou) #5

Thanks for trying to help with this!

I get {{make_a_http_request.data__result__response__data__valuation__sales_average}}

But still nothing is displayed, in the log the error is “message can’t be blank"

(John Jackson) #6

Can you try:

{{make_a_http_request.data__response__data__valuation__sales_average}}
1 Like
(Chris Kyriacou) #7

Sorry John, my bad that is actually what I tried.

Maybe it’s the webhook that has the issue? Am I right on putting all the attributes into the URL or wont it work that way? Do I instead need to put them in separately into “Data to be sent with the request, in key/value pairs.”

To be honest I tried that too…

Lol, I don’t want to waste too much of your time on this, you’ve been great I obviously just dont have the skill level required.

(John Jackson) #8

I don’t think it’s that. TBH I’ve kind of run out of ideas, it should work!

You don’t need to leave it in limbo we will be happy to work with you to resolve, please email us on support :+1:

(Chris Kyriacou) #9

Got it working!!

The response was actually slightly different to the one I showed, I had to remove “valuation”

Thank you for all your help.

2 Likes