I have a payload to get data through REST API, in which I need to get data.
In Visual Flow Creator I got the output properly without any error but in node-red while doing the same flow I'm getting a forbidden error.
Regards
Tharun Balaji
I have a payload to get data through REST API, in which I need to get data.
In Visual Flow Creator I got the output properly without any error but in node-red while doing the same flow I'm getting a forbidden error.
Regards
Tharun Balaji
Welcome to the forums @Tharun
Before anyone can begin to help: please provide the flow you're trying to develop.
and importantly, how you're providing the auth headers (if any) for that REST API command.
please provide the export of the flow between 3 backticks.
```
Flow JSON
```
Payload Data
URL: http://166.0.244.183:8080/handle
Header :
{“accessID”: “<TOKEN>”}
Token ID:257f30f0-a7b5-4c41-baa8-6ad1f90902d7
body: {
"action": "dashboard/getWaterFlow",
"payload": {
"sensor_type": 1,
"asset_status": null,
"spec_id": null,
"location_id": null,
"customer_id": null,
"asset_id": 89,
"from":"2024-04-10T00:00:00Z",
"to":"2024-05-10T00:00:00Z",
"tz":"Asia/Kolkata"
}
While doing this rest call from node red two errors occur
(i) JSON Parse error
(ii) Forbidden causing html page error
But the token is working fine in postman and visual flow creator.But it is not working on node-red. What will be the issue to resolve it?
Regards
Tharun Balaji
Hello! Thank you for your response I hereby attached the payload details along with the screenshot what i have tried till now
Payload Data
URL: http://166.0.244.183:8080/handle
Header : {“accessID”: “”}
Token ID:257f30f0-a7b5-4c41-baa8-6ad1f90902d7
Body: {
"action": "dashboard/getWaterFlow",
"payload": {
"sensor_type": 1,
"asset_status": null,
"spec_id": null,
"location_id": null,
"customer_id": null,
"asset_id": 89,
"from":"2024-04-10T00:00:00Z",
"to":"2024-05-10T00:00:00Z",
"tz":"Asia/Kolkata"
}
While doing this rest call from node red two errors occur
(i) JSON Parse error
(ii) Forbidden causing html page error
But the token is working fine in postman and visual flow creator.But it is not working on node-red. What will be the issue to resolve it?
Regards
Tharun Balaji
Hi @Tharun
You need to post the Text and links of your message as normal and then put the Flow in between the backticks to make it readable. See this link for help in posting any flow.
Hi @mudwalker , I have basic understanding about your format in sending the flow message
[
{
"id": "cdc894e8e67e743d",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "2f700c6bfd101956",
"type": "debug",
"z": "cdc894e8e67e743d",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 710,
"y": 140,
"wires": []
},
{
"id": "90560805f8373913",
"type": "http request",
"z": "cdc894e8e67e743d",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://166.0.244.183:8080/handle",
"tls": "",
"persist": true,
"proxy": "",
"insecureHTTPParser": true,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "accessID",
"valueType": "other",
"valueValue": "257f30f0-a7b5-4c41-baa8-6ad1f90902d7257f30f0-a7b5-4c41-baa8-6ad1f90902d7"
},
{
"keyType": "other",
"keyValue": "Content-Type",
"valueType": "other",
"valueValue": "application/json"
}
],
"x": 390,
"y": 140,
"wires": [
[
"2f700c6bfd101956"
]
]
},
{
"id": "6ef4d680ecb95239",
"type": "inject",
"z": "cdc894e8e67e743d",
"name": "",
"props": [
{
"p": "Payload",
"v": " { \"action\": \"dashboard/getWaterFlow\", \"payload\": { \"sensor_type\": 1, \"asset_status\": null, \"spec_id\": null, \"location_id\": null, \"customer_id\": null, \"asset_id\": 89, \"from\":\"2024-04-10T00:00:00Z\", \"to\":\"2024-05-10T00:00:00Z\", \"tz\":\"Asia/Kolkata\" } }",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"x": 150,
"y": 140,
"wires": [
[
"90560805f8373913"
]
]
}
]
While doing this rest call from node red two errors occur
(i) JSON Parse error
(ii) Forbidden causing html page error
But the token is working fine in postman and visual flow creator.But it is not working on node-red. What will be the issue to resolve it?
{
"id": "cdc894e8e67e743d",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "2f700c6bfd101956",
"type": "debug",
"z": "cdc894e8e67e743d",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 710,
"y": 140,
"wires": []
},
{
"id": "90560805f8373913",
"type": "http request",
"z": "cdc894e8e67e743d",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "[http://166.0.244.183:8080/handle](http://166.0.244.183:8080/handle)",
"tls": "",
"persist": true,
"proxy": "",
"insecureHTTPParser": true,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "accessID",
"valueType": "other",
"valueValue": "257f30f0-a7b5-4c41-baa8-6ad1f90902d7257f30f0-a7b5-4c41-baa8-6ad1f90902d7"
},
{
"keyType": "other",
"keyValue": "Content-Type",
"valueType": "other",
"valueValue": "application/json"
}
],
"x": 390,
"y": 140,
"wires": [
[
"2f700c6bfd101956"
]
]
},
{
"id": "6ef4d680ecb95239",
"type": "inject",
"z": "cdc894e8e67e743d",
"name": "",
"props": [
{
"p": "Payload",
"v": " { \"action\": \"dashboard/getWaterFlow\", \"payload\": { \"sensor_type\": 1, \"asset_status\": null, \"spec_id\": null, \"location_id\": null, \"customer_id\": null, \"asset_id\": 89, \"from\":\"2024-04-10T00:00:00Z\", \"to\":\"2024-05-10T00:00:00Z\", \"tz\":\"Asia/Kolkata\" } }",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"x": 150,
"y": 140,
"wires": [
[
"90560805f8373913"
]
]
}
]
While doing this rest call from node red two errors occur (i) JSON Parse error (ii) Forbidden causing html page error But the token is working fine in postman and visual flow creator.But it is not working on node-red. What will be the issue to resolve it?
Excellent. The last part of your message (While doing this...) could have been sent as normal text, but it is readable. T|he problem with discourse, when posting code as text, is that it will change some characters in the flow and so corrupt it.
We would need to see the message that comes from your http request so that the format is known. (You might want to remove your key from the flow)
Your message comes in through msg.Payload not msg.payload.
Not knowing what you should be getting back from the call, it is difficult to say what you need to do. The statusCode: 400 shows 'Bad Request'. The headers in your HTTP request could be wrong.
Fixed!
Import below
[{"id":"2f700c6bfd101956","type":"debug","z":"cdc894e8e67e743d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":140,"wires":[]},{"id":"90560805f8373913","type":"http request","z":"cdc894e8e67e743d","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://166.0.244.183:8080/handle","tls":"","persist":true,"proxy":"","insecureHTTPParser":true,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"AccessID","valueType":"other","valueValue":"257f30f0-a7b5-4c41-baa8-6ad1f90902d7"},{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"application/json"}],"x":390,"y":140,"wires":[["2f700c6bfd101956"]]},{"id":"6ef4d680ecb95239","type":"inject","z":"cdc894e8e67e743d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":" { \"action\": \"dashboard/getWaterFlow\", \"payload\": { \"sensor_type\": 1, \"asset_status\": null, \"spec_id\": null, \"location_id\": null, \"customer_id\": null, \"asset_id\": 89, \"from\":\"2024-04-10T00:00:00Z\", \"to\":\"2024-05-10T00:00:00Z\", \"tz\":\"Asia/Kolkata\" } }","payloadType":"json","x":150,"y":140,"wires":[["90560805f8373913"]]}]
Side Note: be careful about providing Secrets, Tokens, Access ID's on a public forum
I would regenerate it before moving on for safety.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.