Http request header variables issue

Hi Everyone.
After searching for a while, I’ve decided to post my first message here. I’m sure it must be a detail but I can’t find it.
I did a successful job on “make.com” and would like to reproduce it on n8n. it’s just an http post request.
But I have a problem to pass a variable in the header.
The API i use works well (with curl or make.com) . I even tested with “webhook.site”, and without the headers my request works fine.

So see headers here :
Capture d’écran 2022-06-27 à 15.58.31

and the result message :

I also tried the syntax shown here: HTTP Request - n8n Documentation , but I get an error in the editor , see :

Capture d’écran 2022-06-27 à 16.05.08

I also tried to deactivate “json/raw parameters” but it ends with an error 400 althought with the same on make.com works :frowning:

if anyone has any idea to help me with this error that would be great

thanks very much

have a nice day

Hey @nbweb,

Welcome to the community :tada:

In your last test with the 400 error was that against webhook.site or the service you want to interact with? As a quick test I have fired off 2 requests to webhook.site and both work there which is a good sign.

If you have information on the API you are connecting to or a curl command that works that would be a big help in working it out.

Hi @jon , thanks for your answer.

with webhook it’s all ok . error 400 is when i call the real api. on make.com i’ve done the “same” thing and it worked without problems neither error 400. That’s why I think it’s probably a syntax error on n8n

Hey @nbweb,

It could be a syntax error but the server is saying it won’t work on the request so it would be very useful to know what the server is expecting so we can get n8n sending the same thing. We can try a lot of things but maybe the service is execting a certain field name and we don’t set that.

you can find documentation and exemples here : Documentation API GEODIS

it’s a project for a future client so I’m not very comfortable posting my workflow here with his credentials :-/

The credentials shouldn’t be needed it was just those docs so I can see how they compare to what you are trying. The first thing I have noticed is the X-Service header you are sending is not correct and it looks like it should be X-GEODIS-Service the next potential issue could be the value of that string as it looks like they want the values to be signed / hashed for verification just to make things fun.

What I can tell you looking at those docs though is that it will work with n8n but there could be a bit of work involved,

yes I had deliberately hidden the term “geodis” in the header on my first message…
and yes my workflow is already in several steps precisely to be able to define the hash and the concatenation of strings before making the http request

there are credentials, but they are set in the headers (i don’t know why) and not in basic auth

Hey @nbweb,

Sadly hiding stuff isn’t always helpful, At the moment I have a screenshot showing the wrong information with a 400 error.

I would say looking at the page if you are sending the correct information and you are still getting a 400 error back I would ge tin touch with Geodis and see if they can confirm that the data being sent is correct, They should be able to say if something is missing or is not in the right place.

I suspect there is something different in the Make workflow but to be able to work that out we would need to be able to see both workflows fully with credentials replaced with dummy values.

and the make version

{
    "name": "Integration Tools, HTTP",
    "flow": [
        {
            "id": 7,
            "module": "util:SetVariables",
            "version": 1,
            "parameters": {},
            "mapper": {
                "scope": "execution",
                "variables": [
                    {
                        "name": "login",
                        "value": "dummy-loginValue"
                    },
                    {
                        "name": "secretkey",
                        "value": "dummy-secretkey"
                    },
                    {
                        "name": "lang",
                        "value": "fr"
                    },
                    {
                        "name": "timestamp",
                        "value": "{{timestamp * 1000}}"
                    },
                    {
                        "name": "service",
                        "value": "api/zoomclient/recherche-envois"
                    },
                    {
                        "name": "uri",
                        "value": "https://espace-client.geodis.com/services/"
                    },
                    {
                        "name": "inlinebody",
                        "value": "{\n\t\"dateDepartDebut\": \"2022-06-20\",\n\t\"dateDepartFin\": \"2022-06-20\"\n}"
                    }
                ]
            },
            "metadata": {
                "designer": {
                    "x": 0,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "scope": {
                            "label": "One execution"
                        },
                        "variables": {
                            "items": [
                                null,
                                null,
                                null,
                                null,
                                null,
                                null,
                                null
                            ]
                        }
                    }
                },
                "expect": [
                    {
                        "name": "variables",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "type": "array",
                        "label": "Variables"
                    },
                    {
                        "name": "scope",
                        "type": "select",
                        "label": "Variable lifetime",
                        "required": true,
                        "validate": {
                            "enum": [
                                "roundtrip",
                                "execution"
                            ]
                        }
                    }
                ],
                "interface": [
                    {
                        "name": "login",
                        "type": "any",
                        "label": "login"
                    },
                    {
                        "name": "secretkey",
                        "type": "any",
                        "label": "secretkey"
                    },
                    {
                        "name": "lang",
                        "type": "any",
                        "label": "lang"
                    },
                    {
                        "name": "timestamp",
                        "type": "any",
                        "label": "timestamp"
                    },
                    {
                        "name": "service",
                        "type": "any",
                        "label": "service"
                    },
                    {
                        "name": "uri",
                        "type": "any",
                        "label": "uri"
                    },
                    {
                        "name": "inlinebody",
                        "type": "any",
                        "label": "inlinebody"
                    }
                ]
            }
        },
        {
            "id": 8,
            "module": "util:SetVariables",
            "version": 1,
            "parameters": {},
            "mapper": {
                "scope": "execution",
                "variables": [
                    {
                        "name": "message",
                        "value": "{{7.secretkey}};{{7.login}};{{7.timestamp}};{{7.lang}};{{7.service}};{{7.inlinebody}}"
                    }
                ]
            },
            "metadata": {
                "designer": {
                    "x": 300,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "scope": {
                            "label": "One execution"
                        },
                        "variables": {
                            "items": [
                                null
                            ]
                        }
                    }
                },
                "expect": [
                    {
                        "name": "variables",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "type": "array",
                        "label": "Variables"
                    },
                    {
                        "name": "scope",
                        "type": "select",
                        "label": "Variable lifetime",
                        "required": true,
                        "validate": {
                            "enum": [
                                "roundtrip",
                                "execution"
                            ]
                        }
                    }
                ],
                "interface": [
                    {
                        "name": "message",
                        "type": "any",
                        "label": "message"
                    }
                ]
            }
        },
        {
            "id": 10,
            "module": "util:SetVariables",
            "version": 1,
            "parameters": {},
            "mapper": {
                "scope": "execution",
                "variables": [
                    {
                        "name": "hash",
                        "value": "{{sha256(8.message)}}"
                    }
                ]
            },
            "metadata": {
                "designer": {
                    "x": 600,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "scope": {
                            "label": "One execution"
                        },
                        "variables": {
                            "items": [
                                null
                            ]
                        }
                    }
                },
                "expect": [
                    {
                        "name": "variables",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "type": "array",
                        "label": "Variables"
                    },
                    {
                        "name": "scope",
                        "type": "select",
                        "label": "Variable lifetime",
                        "required": true,
                        "validate": {
                            "enum": [
                                "roundtrip",
                                "execution"
                            ]
                        }
                    }
                ],
                "interface": [
                    {
                        "name": "hash",
                        "type": "any",
                        "label": "hash"
                    }
                ]
            }
        },
        {
            "id": 13,
            "module": "util:SetVariables",
            "version": 1,
            "parameters": {},
            "mapper": {
                "scope": "roundtrip",
                "variables": [
                    {
                        "name": "serviceRequestHeader",
                        "value": "{{7.login}};{{7.timestamp}};{{7.lang}};{{10.hash}}"
                    }
                ]
            },
            "metadata": {
                "designer": {
                    "x": 900,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "scope": {
                            "label": "One cycle"
                        },
                        "variables": {
                            "items": [
                                null
                            ]
                        }
                    }
                },
                "expect": [
                    {
                        "name": "variables",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "type": "array",
                        "label": "Variables"
                    },
                    {
                        "name": "scope",
                        "type": "select",
                        "label": "Variable lifetime",
                        "required": true,
                        "validate": {
                            "enum": [
                                "roundtrip",
                                "execution"
                            ]
                        }
                    }
                ],
                "interface": [
                    {
                        "name": "serviceRequestHeader",
                        "type": "any",
                        "label": "serviceRequestHeader"
                    }
                ]
            }
        },
        {
            "id": 1,
            "module": "http:ActionSendData",
            "version": 3,
            "parameters": {
                "handleErrors": false,
                "useNewZLibDeCompress": true
            },
            "mapper": {
                "ca": "",
                "qs": [],
                "url": "https://webhook.site/4df017ae-cd06-4739-9dc9-693fdad7b791",
                "data": "{{7.inlinebody}}",
                "gzip": true,
                "method": "post",
                "headers": [
                    {
                        "name": "X-GEODIS-Service",
                        "value": "{{13.serviceRequestHeader}}"
                    },
                    {
                        "name": "Content-Type",
                        "value": "application/json; charset=utf-8"
                    },
                    {
                        "name": "Content-Length",
                        "value": "{{length(7.inlinebody)}}"
                    }
                ],
                "timeout": "",
                "useMtls": false,
                "authPass": "",
                "authUser": "",
                "bodyType": "raw",
                "contentType": "application/json",
                "serializeUrl": false,
                "shareCookies": false,
                "parseResponse": true,
                "followRedirect": true,
                "useQuerystring": false,
                "followAllRedirects": false,
                "rejectUnauthorized": true
            },
            "metadata": {
                "designer": {
                    "x": 1200,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "qs": {
                            "mode": "chose"
                        },
                        "method": {
                            "mode": "chose",
                            "label": "POST"
                        },
                        "headers": {
                            "mode": "chose",
                            "items": [
                                null,
                                null,
                                null
                            ]
                        },
                        "bodyType": {
                            "label": "Raw"
                        },
                        "contentType": {
                            "label": "JSON (application/json)"
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "handleErrors",
                        "type": "boolean",
                        "label": "Evaluate all states as errors (except for 2xx and 3xx )",
                        "required": true
                    },
                    {
                        "name": "useNewZLibDeCompress",
                        "type": "hidden"
                    }
                ],
                "expect": [
                    {
                        "name": "url",
                        "type": "url",
                        "label": "URL",
                        "required": true
                    },
                    {
                        "name": "serializeUrl",
                        "type": "boolean",
                        "label": "Serialize URL",
                        "required": true
                    },
                    {
                        "name": "method",
                        "type": "select",
                        "label": "Method",
                        "required": true,
                        "validate": {
                            "enum": [
                                "get",
                                "head",
                                "post",
                                "put",
                                "patch",
                                "delete",
                                "options"
                            ]
                        }
                    },
                    {
                        "name": "headers",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Value"
                            }
                        ],
                        "type": "array",
                        "label": "Headers"
                    },
                    {
                        "name": "qs",
                        "spec": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Name",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Value"
                            }
                        ],
                        "type": "array",
                        "label": "Query String"
                    },
                    {
                        "name": "bodyType",
                        "type": "select",
                        "label": "Body type",
                        "validate": {
                            "enum": [
                                "raw",
                                "x_www_form_urlencoded",
                                "multipart_form_data"
                            ]
                        }
                    },
                    {
                        "name": "parseResponse",
                        "type": "boolean",
                        "label": "Parse response",
                        "required": true
                    },
                    {
                        "name": "authUser",
                        "type": "text",
                        "label": "User name"
                    },
                    {
                        "name": "authPass",
                        "type": "password",
                        "label": "Password"
                    },
                    {
                        "name": "timeout",
                        "type": "uinteger",
                        "label": "Timeout",
                        "validate": {
                            "max": 300,
                            "min": 1
                        }
                    },
                    {
                        "name": "shareCookies",
                        "type": "boolean",
                        "label": "Share cookies with other HTTP modules",
                        "required": true
                    },
                    {
                        "name": "ca",
                        "type": "cert",
                        "label": "Self-signed certificate"
                    },
                    {
                        "name": "rejectUnauthorized",
                        "type": "boolean",
                        "label": "Reject connections that are using unverified (self-signed) certificates",
                        "required": true
                    },
                    {
                        "name": "followRedirect",
                        "type": "boolean",
                        "label": "Follow redirect",
                        "required": true
                    },
                    {
                        "name": "useQuerystring",
                        "type": "boolean",
                        "label": "Disable serialization of multiple same query string keys as arrays",
                        "required": true
                    },
                    {
                        "name": "gzip",
                        "type": "boolean",
                        "label": "Request compressed content",
                        "required": true
                    },
                    {
                        "name": "useMtls",
                        "type": "boolean",
                        "label": "Use Mutual TLS",
                        "required": true
                    },
                    {
                        "name": "contentType",
                        "type": "select",
                        "label": "Content type",
                        "validate": {
                            "enum": [
                                "text/plain",
                                "application/json",
                                "application/xml",
                                "text/xml",
                                "text/html",
                                "custom"
                            ]
                        }
                    },
                    {
                        "name": "data",
                        "type": "buffer",
                        "label": "Request content"
                    },
                    {
                        "name": "followAllRedirects",
                        "type": "boolean",
                        "label": "Follow all redirect",
                        "required": true
                    }
                ]
            }
        },
        {
            "id": 15,
            "module": "builtin:BasicFeeder",
            "version": 1,
            "parameters": {},
            "mapper": {
                "array": "{{1.data.contenu}}"
            },
            "metadata": {
                "designer": {
                    "x": 1500,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "array": {
                            "mode": "edit"
                        }
                    }
                },
                "expect": [
                    {
                        "mode": "edit",
                        "name": "array",
                        "spec": [],
                        "type": "array",
                        "label": "Array"
                    }
                ]
            }
        },
        {
            "id": 17,
            "module": "email:ActionSendEmail",
            "version": 7,
            "parameters": {
                "account": 371751,
                "saveAfterSent": false
            },
            "mapper": {
                "cc": [],
                "to": [
                    "test[at]gmail.com"
                ],
                "bcc": [],
                "from": "",
                "html": "{{15.nomExp}}\n{{15.villeDest}}\n{{15.urlSuiviDestinataire}}\n{{15.urlPreuveService}}\n{{15.urlImageEnlevementLivraison}}",
                "sender": "",
                "headers": [],
                "replyTo": "",
                "subject": "Test Make",
                "priority": "normal",
                "inReplyTo": "",
                "references": [],
                "attachments": [],
                "contentType": "html"
            },
            "metadata": {
                "designer": {
                    "x": 1800,
                    "y": 0
                },
                "restore": {
                    "expect": {
                        "cc": {
                            "mode": "chose"
                        },
                        "to": {
                            "mode": "chose",
                            "items": [
                                null
                            ]
                        },
                        "bcc": {
                            "mode": "chose"
                        },
                        "priority": {
                            "label": "Normal"
                        },
                        "references": {
                            "mode": "chose"
                        },
                        "attachments": {
                            "mode": "chose"
                        },
                        "contentType": {
                            "label": "HTML"
                        }
                    },
                    "parameters": {
                        "account": {
                            "data": {
                                "scoped": "true",
                                "connection": "smtp"
                            },
                            "label": "webmaster sti (SMTP [email protected])"
                        },
                        "saveAfterSent": {
                            "label": "No"
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "account",
                        "type": "account:smtp,google-restricted",
                        "label": "Connection",
                        "required": true
                    },
                    {
                        "name": "saveAfterSent",
                        "type": "select",
                        "label": "Save message after sending",
                        "required": true,
                        "validate": {
                            "enum": [
                                true,
                                false
                            ]
                        }
                    }
                ],
                "expect": [
                    {
                        "name": "to",
                        "spec": {
                            "name": "value",
                            "type": "email",
                            "label": "Email address",
                            "required": true
                        },
                        "type": "array",
                        "label": "To",
                        "required": true
                    },
                    {
                        "name": "subject",
                        "type": "text",
                        "label": "Subject"
                    },
                    {
                        "name": "contentType",
                        "type": "select",
                        "label": "Content Type",
                        "required": true,
                        "validate": {
                            "enum": [
                                "html",
                                "text"
                            ]
                        }
                    },
                    {
                        "name": "attachments",
                        "spec": [
                            {
                                "name": "fileName",
                                "type": "filename",
                                "label": "File name",
                                "required": true,
                                "semantic": "file:name"
                            },
                            {
                                "name": "data",
                                "type": "buffer",
                                "label": "Data",
                                "required": true,
                                "semantic": "file:data"
                            },
                            {
                                "name": "cid",
                                "type": "text",
                                "label": "Content-ID"
                            }
                        ],
                        "type": "array",
                        "label": "Attachments"
                    },
                    {
                        "name": "cc",
                        "spec": {
                            "name": "value",
                            "type": "email",
                            "label": "Email address"
                        },
                        "type": "array",
                        "label": "Copy recipient"
                    },
                    {
                        "name": "bcc",
                        "spec": {
                            "name": "value",
                            "type": "email",
                            "label": "Email address"
                        },
                        "type": "array",
                        "label": "Blind copy recipient"
                    },
                    {
                        "name": "from",
                        "type": "text",
                        "label": "From"
                    },
                    {
                        "name": "sender",
                        "type": "text",
                        "label": "Sender"
                    },
                    {
                        "name": "replyTo",
                        "type": "text",
                        "label": "Reply-To"
                    },
                    {
                        "name": "inReplyTo",
                        "type": "text",
                        "label": "In-Reply-To"
                    },
                    {
                        "name": "references",
                        "spec": {
                            "name": "value",
                            "type": "text",
                            "label": "Reference",
                            "required": true
                        },
                        "type": "array",
                        "label": "References"
                    },
                    {
                        "name": "priority",
                        "type": "select",
                        "label": "Priority",
                        "validate": {
                            "enum": [
                                "high",
                                "normal",
                                "low"
                            ]
                        }
                    },
                    {
                        "name": "headers",
                        "spec": [
                            {
                                "name": "key",
                                "type": "text",
                                "label": "Key",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Value",
                                "required": true
                            }
                        ],
                        "type": "array",
                        "label": "Headers"
                    },
                    {
                        "name": "html",
                        "type": "text",
                        "label": "Content"
                    }
                ]
            }
        }
    ],
    "metadata": {
        "instant": false,
        "version": 1,
        "scenario": {
            "roundtrips": 1,
            "maxErrors": 3,
            "autoCommit": true,
            "autoCommitTriggerLast": true,
            "sequential": false,
            "confidential": false,
            "dataloss": false,
            "dlq": false
        },
        "designer": {
            "orphans": []
        },
        "zone": "eu1.make.com"
    }
}

They look to be pretty close, I will have a proper look through the workflow and the docs a bit later when I get a chance and do some tests with the code samples they provide to see if the generated values are the same.

1 Like

That would be really nice of you, thank you very much!!

i just saw that actually there are demo credentials : (Documentation API GEODIS)
login : DEMO
secret key : 12345678