drudge / n8n-nodes-netsuite

n8n node for interacting with NetSuite using SuiteTalk REST Web Services
MIT License
11 stars 6 forks source link

INVALID_CONTENT error in raw request with patch HTTP method #5

Open navidadelpour opened 8 months ago

navidadelpour commented 8 months ago

The raw request as demonstrated below: image Is not working and gives:

[
  {
    "type": "https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.1",
    "title": "Bad Request",
    "status": 400,
    "o:errorDetails": [
      {
        "detail": "Invalid content in the request body.",
        "o:errorCode": "INVALID_CONTENT"
      }
    ]
  }
]

But in the postman it is working properly (gives 204 code) image

navidadelpour commented 8 months ago

Hi @drudge @ubtashton Am I making a mistake? I've checked the source code and in NetSuite.node.ts#L305 it sets query = body. does it creates the problem?

navidadelpour commented 8 months ago

Ok, I've figured it out. I used a Set node before the NetSuite Node and removed the body parameter like this: image

And query would use item.json instead of the body field (const query = body || (item ? item.json : undefined);).

I guess that the root of the problem is that the body is string (const body = fns.getNodeParameter('body', itemIndex) as string;) but the query expects to receive an object.

Should I fix this in a PR? @drudge