You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am doing an HTTP POST request to the Bubble data API endpoint and it breaks every time that there is a null value in a number field.
What is the error message (if any)?
Problem in node ‘HTTP Request‘
JSON parameter needs to be valid JSON
NodeOperationError: JSON parameter needs to be valid JSON at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:207:39) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:632:42) at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:872:62 at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1206:20
Merged Data in Right Panel of Expression Editor OK - Sent successfully to target endpoint using Postman
Send to webhook.site (like RequestBin) successful with number but not received with Null
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
0,
0
],
"id": "2eae0ebe-1b7f-401f-9aba-e70647b1b1ba",
"name": "When clicking ‘Test workflow’"
},
{
"parameters": {
"operation": "executeQuery",
"query": "WITH group_counts AS (\n -- Get the count of records for each question_group_id\n SELECT\n question_group_id,\n COUNT(*) AS cnt\n FROM NFL_team_year_trivia_subset_tf_eq_sa\n GROUP BY question_group_id\n),\ngroup_totals AS (\n -- Calculate the running total over the groups when sorted by question_group_id.\n -- The running_total value for a group is the sum of counts of all groups up to and including that group.\n SELECT\n question_group_id,\n cnt,\n SUM(cnt) OVER (ORDER BY question_group_id ROWS UNBOUNDED PRECEDING) AS running_total\n FROM group_counts\n),\nselected_groups AS (\n -- Select groups so that we include the whole group,\n -- even if adding it causes the overall record count to exceed 200.\n -- We do this by checking that the cumulative total just before adding the current group is less than 200.\n SELECT\n question_group_id\n FROM group_totals\n WHERE running_total - cnt < 200\n)\nSELECT *\nFROM NFL_team_year_trivia_subset_tf_eq_sa\nWHERE question_group_id IN (SELECT question_group_id FROM selected_groups)\nORDER BY question_group_id;",
"options": {}
},
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
220,
0
],
"id": "ea867e53-b19f-4e3a-a719-f01cc1eb25d6",
"name": "MySQL",
"credentials": {
"mySql": {
"id": "arg0oCTvZqa7HiNw",
"name": "MySQL account"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "82f99108-a365-404e-a464-8580f3cba8fb",
"name": "id_nfl_team_year_data",
"value": "={{ $json.id_nfl_team_year_data }}",
"type": "number"
},
{
"id": "e5341025-8607-4903-bcd9-89e85c7229da",
"name": "question",
"value": "={{ $json.question }}",
"type": "string"
},
{
"id": "1d9bb3eb-6c30-4813-92e0-baf809d37e03",
"name": "answer",
"value": "={{ $json.answer }}",
"type": "string"
},
{
"id": "95180659-a469-4f97-a45f-969058cc40a2",
"name": "=boolean_true_false",
"value": "={{ $json.boolean_true_false }}",
"type": "number"
},
{
"id": "b9f9ca80-c457-495c-a675-bce41b170f98",
"name": "Alternate_01",
"value": "={{ $json.Alternate_01 }}",
"type": "string"
},
{
"id": "c56ccb12-2ee8-4c72-b824-ac1e951d0e48",
"name": "Alternate_02",
"value": "={{ $json.Alternate_02 }}",
"type": "string"
},
{
"id": "06192020-8188-4807-b24a-c532106dcfbb",
"name": "Alternate_03",
"value": "={{ $json.Alternate_03 }}",
"type": "string"
},
{
"id": "1171173f-ba38-473e-8a72-c2a267ac67cb",
"name": "data_type",
"value": "={{ $json.data_type }}",
"type": "string"
},
{
"id": "c7db5331-ce5c-4d7e-8f89-facbeb407763",
"name": "question_type",
"value": "={{ $json.question_type }}",
"type": "string"
},
{
"id": "47dac8ed-f681-4964-98bb-ff0eb6fcdb82",
"name": "source",
"value": "NFL_team_year_trivia",
"type": "string"
},
{
"id": "aae514ab-62fb-449a-b8f6-709a6e6415c9",
"name": "answer_number",
"value": "={{ $json.answer_number }}",
"type": "number"
},
{
"id": "4198590d-f6e6-4332-b755-26405f78ac56",
"name": "question_group_id",
"value": "={{ $json.question_group_id }}",
"type": "string"
},
{
"id": "44d5cffe-2291-4e30-adf6-9fcb3098ba0a",
"name": "answer_date_unix",
"value": "={{ $json.answer_date_unix }}",
"type": "number"
},
{
"id": "98e219bd-d434-4ed4-9f3c-204c92b871ad",
"name": "unix2text_date",
"value": "={{ $json.unix2text_date }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
760,
0
],
"id": "0dd239b2-db41-4261-b61d-2546abcd4057",
"name": "Edit Fields"
},
{
"parameters": {
"jsCode": "// This function converts a Unix timestamp (in seconds) into a formatted date string.\nfunction formatUnixTimestamp(ts) {\n // If the timestamp is null or invalid, return a default message.\n if (ts == null) {\n return 'Invalid Date';\n }\n \n // Convert the Unix timestamp from seconds to milliseconds and create a Date object.\n const date = new Date(ts * 1000);\n \n // Helper function: pads a number with a leading zero if needed.\n const pad = num => String(num).padStart(2, '0');\n \n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1); // Note: Months are zero-based, so add 1.\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const seconds = pad(date.getSeconds());\n \n // Return the formatted date string.\n return `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;\n}\n\n// Loop over each input item that comes into this node.\nfor (const item of $input.all()) {\n \n // *** IMPORTANT: Make sure that each input item's JSON has a property called 'timestamp'\n // that contains the Unix timestamp you want to convert. ***\n // For example, your input item should look like: { \"timestamp\": 1672531199, ... }\n \n // Get the Unix timestamp from the input item.\n const inputTimestamp = item.json.answer_date_unix;\n \n // Convert the Unix timestamp using our helper function.\n // The result will be a string in the format YYYY-MM-DD-hh-mm-ss.\n item.json.unix2text_date = formatUnixTimestamp(inputTimestamp);\n}\n\n// Return all modified items.\nreturn $input.all();\n\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
520,
0
],
"id": "0bb5c387-e230-4811-8659-0758f8d1b18f",
"name": "Code1"
},
{
"parameters": {
"method": "POST",
"url": "https://decisive-edge.ca/version-test/api/1.1/obj/Raw_Import_Cuestion_Rec",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "XXXXXXXX"
},
{
"name": "content-type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n\"id_de_Fuente\": {{ $json.id_nfl_team_year_data }},\n\"Cuestion\": \"{{ $json.question }}\",\n\"Respuesta_Tipo_Texto\": \"{{ $json.answer }}\",\n\"Respues_Fecha_Unix2text\": \"{{ $json.unix2text_date }}\",\n\"Respuesta_Unix_Fecha\": {{ $json.answer_date_unix }},\n\"Respuesta_Tipo_Numero\": {{ $json.answer_number }},\n\"Alternativa_01\": \"{{ $json.Alternate_01 }}\",\n\"Alternativa_02\": \"{{ $json.Alternate_02 }}\",\n\"Alternativa_03\": \"{{ $json.Alternate_03 }}\",\n\"Cuestion_tipo_de_datos\": \"{{ $json.data_type }}\",\n\"Formato_cuestion_respuesta\": \"{{ $json.question_type }}\",\n\"Fuente\": \"{{ $json.source }}\",\n\"id_grupo_cuestiones_similares\": \"{{ $json.question_group_id }}\",\n\"Categoria\": \"Sports & Recreation\",\n\"SubCategoria\": \"American Football\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1060,
0
],
"id": "76edcedf-f031-496c-af07-aa6865defc9c",
"name": "HTTP Request"
}
],
"connections": {
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "MySQL",
"type": "main",
"index": 0
}
]
]
},
"MySQL": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[]
]
}
},
"pinData": {
"Edit Fields": [
{
"id_nfl_team_year_data": 44226,
"question": "Who was the leading rusher for the Green Bay Packers in 1969?",
"answer": "Donny Anderson",
"boolean_true_false": 1,
"Alternate_01": "",
"Alternate_02": "",
"Alternate_03": "",
"data_type": "text",
"question_type": "short-answer",
"source": "NFL_team_year_trivia",
"answer_number": 45,
"question_group_id": "00020c72876fa8a75c3c98eab3e83bbf8199919d76f226fed619ec7324aa8cb6",
"answer_date_unix": null,
"unix2text_date": "Invalid Date"
}
]
},
"meta": {
"instanceId": "6e81e84bc73c0f0a5aa478802f31fa7e9701532814d992ca6316211ee662eeb1"
}
}
## Share the output returned by the last node
<!-- If you need help with data transformations, please also share your expected output. -->
Last node output is the error given at the start. ie HTTP Request Node is last node.
The last node does execute properly when the value for the field with data type number is a number as opposed to a null value.
The value when it is successful is :
[
{
"status": "success",
"id": "1737485202816x130336756277867460"
}
]
Input from previous node is
[
{
"id_nfl_team_year_data": 44226,
"question": "Who was the leading rusher for the Green Bay Packers in 1969?",
"answer": "Donny Anderson",
"boolean_true_false": 1,
"Alternate_01": "",
"Alternate_02": "",
"Alternate_03": "",
"data_type": "text",
"question_type": "short-answer",
"source": "NFL_team_year_trivia",
"answer_number": 45,
"question_group_id": "00020c72876fa8a75c3c98eab3e83bbf8199919d76f226fed619ec7324aa8cb6",
"answer_date_unix": null,
"unix2text_date": "Invalid Date"
}
]
## Debug info
### core
- n8nVersion: 1.74.3
- platform: npm
- nodeJsVersion: 20.18.1
- database: sqlite
- executionMode: regular
- concurrency: 5
- license: community
### storage
- success: all
- error: all
- progress: false
- manual: true
- binaryMode: filesystem
### pruning
- enabled: true
- maxAge: 168 hours
- maxCount: 2500 executions
### client
- userAgent: mozilla/5.0 (windows nt 10.0; win64; x64; rv:134.0) gecko/20100101 firefox/134.0
- isTouchDevice: false
Generated at: 2025-01-21T14:52:49.201Z}
The text was updated successfully, but these errors were encountered:
I see you accidentally shared your authorization header with the workflow. I removed it from your post, but you might want to rotate it since it was shared publicly. I would also recommend defining the auth header as a credential, so it's not visible or included when you share the workflow.
I'll have a look at the issue to see if I can reproduce it.
Describe the problem/error/question
I am doing an HTTP POST request to the Bubble data API endpoint and it breaks every time that there is a null value in a number field.
What is the error message (if any)?
Problem in node ‘HTTP Request‘
JSON parameter needs to be valid JSON
NodeOperationError: JSON parameter needs to be valid JSON at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:207:39) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:632:42) at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:872:62 at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1206:20
Please share your workflow/screenshots/recording
Video with full explanation
https://youtu.be/WMyH3bSi_8I
Success with Number
Failure with Null
Merged Data in Right Panel of Expression Editor OK - Sent successfully to target endpoint using Postman
Send to webhook.site (like RequestBin) successful with number but not received with Null
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
The text was updated successfully, but these errors were encountered: