Not able to get response from http request

Hi,
this is the first time i use node-red.
I tried to create a flow with http in and get the response.
But when i go to : http://127.0.0.1:1880/trade
i see Cannot GET /trade

I would like to see the response in json format

here is the flow:
u need the replace the token

[
{
"id": "4e283e7e.2b78a",
"type": "tab",
"label": "trade",
"disabled": false,
"info": ""
},
{
"id": "96fb3786.88f1d8",
"type": "http response",
"z": "4e283e7e.2b78a",
"name": "trade response",
"statusCode": "200",
"headers": {

},
"x": 500,
"y": 140,
"wires": [
  
]

},
{
"id": "e5e06e48.7d2b9",
"type": "http in",
"z": "4e283e7e.2b78a",
"name": "trade request",
"url": "https://api.worldtradingdata.com/api/v1/stock?symbol=TSLA&api_token=paste-token-here",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 210,
"y": 140,
"wires": [
[
"28a2346d.a82e3c"
]
]
},
{
"id": "28a2346d.a82e3c",
"type": "template",
"z": "4e283e7e.2b78a",
"name": "Template",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "This is the payload: {{payload}} !",
"output": "json",
"x": 340,
"y": 220,
"wires": [
[
"96fb3786.88f1d8"
]
]
}
]

The HTTP In node is used to define the endpoint within Node-RED that responds to HTTP requests.

If you want it to respond to http://127.0.0.1:1880/trade then the HTTP In node should be configured with a url of /trade.

If you want the flow to then make an HTTP Request to the worldtradingdata api you currently have in the HTTP In node, then you need to add an HTTP Request node to the flow and use that to make the request.

The cookbook has lots of examples for using the different HTTP nodes - it may be worth spending a bit of time working through that so you are familiar with the different nodes - cookbook.nodered.org

Hi,
thank you for your answer.
i did check at first the cookbook and i found Simple Get request example.
But i'm trying to get response from api service.
If i paste the url directly in google chrome then i get the response in json format.
I wanted to do the same with node-red because later i want to extract some data from the json.
So i tried your second suggestion and i get nothing, HTTP Request (url=https://api.worldtradingdata.com/api/v1/stock?symbol=TSLA&api_token=)
Then i added a second HTTP Request but i suppose it's HTTP Response, i tried both
Cannot GET /trade here trade is the name of the Flow right?

Does your flow look like this?

trigger (start the process)
  -> http-request (with the api URL to get the data from the web api)
    -> debug (to show the data returned from the api)

If not, try with that first.

Yes my flow is like you desribed.
But still i don't get any response.
i expect to see the response in json format.

Unfortunately, I don't have an API key for that site so I can't test it. Try just outputting plain text from the http-request in case something odd is happening with the parsing.

Can you share the flow you have tried so we can see for certain what you are now trying?

just go there https://www.worldtradingdata.com/ and register then u get api key.
it s free.

You need to use the http-request node, not the http-in/response nodes.

1 Like

Works fine for me using http-request as @bakman2 suggested.

Yes it works now.
i used the inject node and i forgot to click on the button of inject node.
Thank you very much to all of you.
we can close this thread.

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