Http request header and body

Hi there,
I need to send data via https request to an API and did not get it on track. Perhaps you have a recommendation.

I have this PUT header (with some anonymisations :-)):
PUT /kd_1/api/V1/Profilcandidate HTTP/1.1
Host: myyyyyy.yyyyyyy.de
Content-Type: application/json
SubscriptionKey: yyyyyyyyyyyyy
Cookie: ASP.NET_SessionId=amvnsan5xhy20sxeuxdqxb4s; F5BigIP=!gyJ/pzpakRhJprJ0vD7SpFy8MsbEt6o7K/m0KbBaN0DWq+n4GyfKh734htUh5gbxBfDEYnJwqlw+9SoDiYGXwbjScSHCC6x4y9Es1sgV; TS016adc98=017a0f52b0cb90501b08d832606738d989b6179e413690b1d82fdd7d3463f42df9468165f37fea0244a679dff148704cf8fa1a784d
Content-Length: 422

and this body:
{
“Country”: “DE”,
“BewerberId”: “500845221”,
“Kampagne”: “Test nexum 22/04/21”,
“Source”: “”,
“Answers”: [
{
“Key”: “VerfuegbarAb Value”,
“Value”: “1”
},
{
“Key”: “Entfernung”,
“Value”: “300”
},
{
“Key”: “GehaltswunschProMonat”,
“Value”: “3000”
}
],
“Dokuments”: []
}

And it put it into the fields with this settings! Without Auth because I have just the subscriptionkey in the header.
Bildschirmfoto 2021-04-23 um 10.10.35|645x500

I put the header and body in the parameters field like mentioned above. But it is not working.

Thx and kind regards
Sebastian

Hey hey @mezkalito!

Welcome to the community :tada:

Did you checked the documentation for the HTTP Request node? We also have a blog post explaining how to use the node, you can refer it here: https://n8n.io/blog/how-to-use-the-http-request-node-the-swiss-army-knife-for-workflow-automation/

Hi and thx for welcome me.
I checked the docu, yes, but did not find exactly how to write the header and body in the right way. it seems to be the problem there.
Or if I choose to use this settings below and do not now where to put the answers part from the json.

Thx and regards

Hey!

You can use the current settings that you have and add parameters for each item in your JSON object. Alternatively, you can toggle JSON/RAW Parameter to true (as shown in the image). This will provide you with text fields where you can enter your JSON object.

Let me know if you still have questions :slight_smile:

All right.

But in the json i have values like Country and then values for with keys for answers. How do i set up this? This will be my last question then. :slight_smile: Sorry, I am a little bit lost with this API topics.

Hey!

Feel free to ask questions. I am more than happy to help :slight_smile:

Here’s the HTTP Request node that you can use in your workflow. Make sure to change the values as per your needs.

{
  "nodes": [
    {
      "parameters": {
        "requestMethod": "POST",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "{\n“Country”: “DE”,\n“BewerberId”: “500845221”,\n“Kampagne”: “Test nexum 22/04/21”,\n“Source”: “”,\n“Answers”: [\n{\n“Key”: “VerfuegbarAb Value”,\n“Value”: “1”\n},\n{\n“Key”: “Entfernung”,\n“Value”: “300”\n},\n{\n“Key”: “GehaltswunschProMonat”,\n“Value”: “3000”\n}\n],\n“Dokuments”: []\n}",
        "headerParametersJson": "{\n\"Host\": \"myyyyyy.yyyyyyy.de\",\n\"Content-Type\": \"application/json\"\n\"SubscriptionKey\": \"yyyyyyyyyyyyy\"\n\"Cookie\": \"ASP.NET_SessionId=amvnsan5xhy20sxeuxdqxb4s; F5BigIP=!gyJ/pzpakRhJprJ0vD7SpFy8MsbEt6o7K/m0KbBaN0DWq+n4GyfKh734htUh5gbxBfDEYnJwqlw+9SoDiYGXwbjScSHCC6x4y9Es1sgV; TS016adc98=017a0f52b0cb90501b08d832606738d989b6179e413690b1d82fdd7d3463f42df9468165f37fea0244a679dff148704cf8fa1a784d\"\n\"Content-Length\": \"422\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        644,
        121
      ]
    }
  ],
  "connections": {}
}

You can copy the above code and paste it in the Editor UI.

Ah perfect. Thx a lot.
Just to be clear. I use the complete node. and in which field do i have to fill it?

I would suggest you to take a look at following parameters and make sure they are correct:

  • Request Method - Mistakenly, I have set to POST. Since you need to make a PUT request, please update it.
  • URL - This is empty because I didn’t know which URL you want to access. Enter your URL in this field.
  • Body Parameters - I have copy-pasted the body you shared. Please make changes to it if you want to make a request with different data
  • Headers - You will need update this with correct data

Hope this answers your question :slight_smile:

Not completely. I got, I have to change the some parts but do not now where to copy this node to.

I made it like this now but it does not work:



What is the error that you get?

it is loading and loading and i get no result

Hey @mezkalito,

Do you mind sharing me the URL and other data to make the call. Feel free to send it to me over a DM. The above solution should have worked. I will try to replicate the issue and try to get back with a working solution.

Hey @mezkalito,

I removed the Cookie and the Content Length fields from the headers and I got a success response. I am not certain why this works, but it might depend on the way the API is designed.