URL Logger reply back with custom token

More
2 years 3 months ago - 2 years 3 months ago #23877 by admin
Looks like you have not looked at the link we provided
Code:
const data = { "token": "sewf87w3rp48DMWJLXBhvhSy", "challenge": "GWuXDWpzf8tkuD7aWbNiOqAWYybmpBRl2broar4AI0vCH88KR3I9", "type": "url_verification" }; res.status(200).json(data); ​​​​​​​ return -1; 

Mike
ETL Architect
Last edit: 2 years 3 months ago by admin.

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23878 by admin
Array example
Code:
const data = [ 1,2,3] res.status(200).json(data); ​​​​​​​ return -1; 

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23882 by prashant

Looks like you have not looked at the link we provided
Code:
const data = { "token": "sewf87w3rp48DMWJLXBhvhSy", "challenge": "GWuXDWpzf8tkuD7aWbNiOqAWYybmpBRl2broar4AI0vCH88KR3I9", "type": "url_verification" }; res.status(200).json(data); return -1; 
HI Mike,
Thanks for the replies and putting answers together 


1. I did look at the link. but still didn't understand it .  I understand return -1 for disableing default response so custom response can be used can be used
2. What I don't' understand is if the data is dynamic , that means I don't know the value just the json structure , how we proceed then ? 
Code:
const token = body.token; res.status(200).json({ token: token });

3. in above example , my understand is the entire json is being sent back token including token, challenge,and type. Firstly how do I only reply back with challenge token . Chatgpt says I can try res.status(200).json({ token: data.token }); 

 

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23884 by admin
This code will send back challenge
 
Code:
const data = { "token": "sewf87w3rp48DMWJLXBhvhSy", "challenge": "GWuXDWpzf8tkuD7aWbNiOqAWYybmpBRl2broar4AI0vCH88KR3I9", "type": "url_verification" }; res.status(200).json({ challenge: data.challenge}); return -1; 

You can build any JSON you want dynamically.

I appreciate that you having difficulties but I've found your questions extremely confusing

My data is coming in as part of HTTP header (body)
It looks like this 
1 Incoming data example
Based on this data I would like to send back JSON which looks like this:
2 Response Example

See?

Very easy to understand and provide support

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #23910 by prashant
HI , 
My apologies , being non techie I miss on intricacies , What I meant was the challenge parameter form slack is always dynamic , so 

{"token": "sewf87w3rp48DMWJLXBhvhSy","challenge": "6BhaTRZjXA6qwHbEW4gp7cVCw8n27VocSwuYjPDqR3urx578vahV",  "type": "url_verification"}
{ "token": "sewf87w3rp48DMWJLXBhvhSy", "challenge": "GWuXDWpzf8tkuD7aWbNiOqAWYybmpBRl2broar4AI0vCH88KR3I9", "type": "url_verification" }

But I appreciate the changes you made for me.  I was able to get this to work with below
Code:
try {     res.status(200).json({ challenge: body.challenge });     return -1; } catch (err) {     return 500; }
 

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save