# HTTP Request GET with body

**URL:** <https://community.n8n.io/t/http-request-get-with-body/6249>\
**Category:** Questions\
**Created:** [June 11, 2021, 7:11pm UTC](https://community.n8n.io/t/http-request-get-with-body/6249 "2021-06-11T19:11:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Couto](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/lucas_couto/32/5069_2.png) [@Lucas\_Couto](https://community.n8n.io/u/Lucas_Couto)\
**Post date:** [June 11, 2021, 7:11pm UTC](https://community.n8n.io/t/http-request-get-with-body/6249/1 "2021-06-11T19:11:51Z")

</div>

I’m trying to use Seatable API (self hosted), and before creating a row I’d like to check if it already exists. Unfortunately the API requires GET method with the filters in the body and I can’t do that with n8n (no body field shown when GET selected).

I’m thinking of trying to use execute node to call a python script instead (but have to install python in docker, script it and so).

Any idea on how to overcome this?

This is the API documentation:  
[https://api.seatable.io/#65efccf8-1b3e-49a1-aeed-9df75dcadca9](https://api.seatable.io/#65efccf8-1b3e-49a1-aeed-9df75dcadca9)

thanks in advance

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [June 11, 2021, 7:47pm UTC](https://community.n8n.io/t/http-request-get-with-body/6249/2 "2021-06-11T19:47:30Z")

</div>

Welcome to the community @Lucas_Couto

I would make the HTTP request from a function node instead. By default, requiring packages it’s not allowed, but you can enable it by setting env variables below:

> export NODE\_FUNCTION\_ALLOW\_BUILTIN=util
> 
> export NODE\_FUNCTION\_ALLOW\_EXTERNAL=request

After that, to make a GET request, you can do something similar to:

```auto
const request = require('request')
const { promisify } = require('util');
const rq = promisify(request);

const data = await rq({
uri: "https://pokeapi.co/api/v2/pokemon/ditto",
method: 'GET'
})
return [
  {
    json: JSON.parse(data.body)
  }
];

```

> **Example workflow**
>
> ```
> {
> "nodes": [
> {
> "parameters": {},
> "name": "Start",
> "type": "n8n-nodes-base.start",
> "typeVersion": 1,
> "position": [
> 210,
> 300
> ]
> },
> {
> "parameters": {
> "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\nconst request = require('request')\nconst { promisify } = require('util');\nconst rq = promisify(request);\n\n\nconst data = await rq({\nuri: \"https://pokeapi.co/api/v2/pokemon/ditto\",\nmethod: 'GET'\n})\nreturn [\n {\n json: JSON.parse(data.body)\n }\n];"
> },
> "name": "Function",
> "type": "n8n-nodes-base.function",
> "typeVersion": 1,
> "position": [
> 840,
> 170
> ]
> }
> ],
> "connections": {
> "Start": {
> "main": [
> [
> {
> "node": "Function",
> "type": "main",
> "index": 0
> }
> ]
> ]
> }
> }
> }
> 
> ```

Of course, at all that is assuming that you are self-hosting. If you are using n8n cloud, you do not need to set the env variables.

With regards to not being able to sent a body when doing a GET request. We are aware of that limitation as it’s something that we would include in the version 2 of the node.

> **[Configuration methods | n8n Docs](https://docs.n8n.io/hosting/environment-variables/configuration-methods/)**
>
> How to set environment variables for n8n.

---

<div class="post-metadata">

**Author:** ![sirland](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sirland/32/5740_2.png) [@sirland](https://community.n8n.io/u/sirland)\
**Post date:** [July 27, 2021, 8:57am UTC](https://community.n8n.io/t/http-request-get-with-body/6249/3 "2021-07-27T08:57:52Z")

</div>

Hi @RicardoE105 and @Lucas_Couto,

Sorry, but I have to say that the answer above is incomplete. You cannot pass a body element in the request options if the method is ‘GET’ with the code offered. It will simply ignore it as per the request module specification:

> - `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer`, `String` or `ReadStream`. If `json` is `true`, then `body` must be a JSON-serializable object. (Source: [https://www.npmjs.com/package/request](https://www.npmjs.com/package/request))

@Lucas_Couto if you haven’t figured it out by yourself, you have to use a HAR 1.2 request to get the body to pass. Here’s an example code for your case:

```
const request = require('request');
const { promisify } = require('util');
const rq = promisify(request);

var body = JSON.stringify(
  // Put your request body here
  { 
    "filters":[
      {
        "column_name": "name", 
        "filter_predicate": "contains", 
        "filter_term": "bob", 
        "filter_term_modifier": ""
      },
      {
        "column_name": "name", 
        "filter_predicate": "contains", 
        "filter_term": "john", 
        "filter_term_modifier": ""
      }
    ],
    "filter_conjunction": "Or"
  }
);

const data = await rq({
  har: {
    url: "{{your-server}}/dtable-server/api/v1/dtables/{{your-base-id}}/filtered-rows/?table_name={{table_name}}",
    method: "GET",
    headers: [ 
      {
        name: "Authorization",
        value: "Token {{your-base-token}}"
      }
    ],
    postData: {
      "mimeType": "application/json",
      "text": body
    }  
  }
})
return [
  {
    json: data.body
  }
];

```
