Where must i describe post request header in n8n http request node?

Hello !

For example I have curl REST API post request loading binary file like this

curl --request POST “https://127.0.0.1:4000/api/v1/clients/ee-dev:COM:10264823:maais/tls-certificates” --header “Authorization: X-Road-ApiKey token=b7bb0b1ac3b0” --header “Content-Type: application/octet-stream” --data-binary “@/home/administrator/name.crt” -k

Where must i describe this header “Content-Type: application/octet-stream” in n8n http request node ?

Hey @alolauri,

You can add it as a Header parameter.

Hello !

I choosed “Add header” and added to fields
Name: Content-Type
Value application/octet-stream

But my http requst node displays
ERROR: UNKNOWN ERROR - check the detailed error for more information
415 - {“type”:“Buffer”,“data”:[123,34,115,116,97,116,117,115,34,58,52,49,53,125]}

and ubder the Detail

HTTP-Code
rejected
Cause
Data below may contain sensitive information. Proceed with caution when sharing.
{
"status": "rejected",
"reason": {
"name": "StatusCodeError",
"statusCode": 415,
"message": "415 - {"type":"Buffer","data":[123,34,115,116,97,116,117,115,34,58,52,49,53,125]}",
"error": {
"type": "Buffer",
"data": [...] // 14 items
},
"options": {
"timeout": 3600000,
"headers": {...}, // 3 keys
"method": "POST",
"uri": "https://127.0.0.1:4000/api/v1/clients/ee-dev:COM:10264823:maais/tls-certificates",
"gzip": true,
"rejectUnauthorized": false,
"body": "{}",
"qs": {...}, // 0 keys
"encoding": null,
"simple": true,
"resolveWithFullResponse": false,
"transform2xxOnly": false
},
"response": {
"statusCode": 415,
"body": {
"type": "Buffer",
"data": [
123,
34,
115,
116,
97,
116,
117,
115,
34,
58,
52,
49,
53,
125
]
},
"headers": {
"x-road-ui-correlation-id": "6493251c86f58e44",
"accept": "application/octet-stream",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"cache-control": "no-cache, no-store, max-age=0, must-revalidate",
"pragma": "no-cache",
"expires": "0",
"strict-transport-security": "max-age=31536000 ; includeSubDomains",
"x-frame-options": "DENY",
"content-security-policy": "default-src 'none'",
"content-type": "application/json",
"transfer-encoding": "chunked",
"date": "Fri, 17 Sep 2021 12:14:18 GMT",
"connection": "close"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "127.0.0.1:4000",
"port": "4000",
"hostname": "127.0.0.1",
"hash": null,
"search": null,
"query": null,
"pathname": "/api/v1/clients/ee-dev:COM:10264823:maais/tls-certificates",
"path": "/api/v1/clients/ee-dev:COM:10264823:maais/tls-certificates",
"href": "https://127.0.0.1:4000/api/v1/clients/ee-dev:COM:10264823:maais/tls-certificates"
},
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "X-Road-ApiKey token=c6804432-37f4-43e3-b3f1-b7bb0b1ac3b0",
"accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7",
"accept-encoding": "gzip, deflate",
"content-length": 2
}
}
}
}
} 

And ander the host applictaion where the post request is made there in in log message
Content type ‘application/json’ not supported

:

Are you sending a binary file? If so, you toggle JSON/RAW Parameter option to true and then the Send Binary Data option to true. This will allow you to send a binary file to requested API

Yes 'm sending binary file . Here sceenshot of my http request node window

I changed the http request node configurtation like this but got error . The sceenshot

Try setting the Content-Type with the Body Content Type option. By default it is JSON, hence you’re getting the above error.

I’m cant figure out where must i but my Content-Type: application/octet-stream

You can set the content type as well.

Many thanks This solution worked

1 Like