N8n Community Node: OData

I saw several requests for OData compatibility, so I created this:

Installation
You can install it by typing n8n-nodes-odata in Settings/Community Node Installation on your self-hosted n8n instance.

What is OData?
Created by Microsoft in 2007, OData (Open Data Protocol) is an open protocol that allows the creation and consumption of queryable and interoperable RESTful APIs in a simple and standard way.

Node Features
GET, POST, PATCH, DELETE
Other features: $filter, $select, $orderby, $top, $skip

In addition to the basic features, there is also an input field for inputting a raw JSON query, which will override other options and allows for advanced usage.

100102!!n8n!! — Mozilla Firefox

5 Likes

Nice👍

I think the array is not setup right though. Seems like you have one item with an array coming out of it instead of an array of items.:grin:

1 Like

Ah thanks for pointing that out.
I changed it to output items now:

1 Like

I’m trying to connect to our local instance of SAP API. I can connect successfully with Postman/APIDog with the same info successfully but not with your OData node. In Postman I have to specify Body parameter which is Raw/XML and it creates 2 cookies B1Session & RouteID. I tried using the Advanced option with the XML in the Raw Query field but get an error. Should I be doing this another way?

Thanks for creating this node!

Thanks for the feedback, Tim! When developing this version, I was using a server that didn’t require keeping session that way, so I will have to make some additions to the node after finding a new test server :sunglasses:

That would be awesome! I’ve been looking for a solution to automating the creation of PO’s, SO’s etc in SAP Business One with their API for a while now and I think this node is the answer to my prayers!

I am currently investigating ways to authenticate to oauth2. I believe I have found a way to do it via Generic Authentication.

I’ve just released version 0.2.0 to npm with OAuth support in the node. I’ve tested it with Microsoft Azure so far. If you reinstall the community node, you can let me know if it works for you now. :sunglasses:

1 Like

I will try this out and let you know. Thanks!

1 Like

@tim.berneman I’m curious and in need of something alike. Currently looking for available solutions without developing it myself. Hence; did you manage to get it to work?

Thanks.

No, I never did circle back and try this as I solved my issue without it. I do recommend trying it though as the first iteration looked promising and the author was very responsive.

@tim.berneman you stated that you were trying to create PO’s and SO’s using the SAP Business One Service Layer in n8n. When you say that you solved your issue without it, do you mean that you’ve successfully implemented a solution that automates processes using the SAP Business One Service Layer in n8n? If so; could you elaborate on this solution?

Or did you end up not using n8n?

Looking forward to hearing from you, thanks.

I don’t much time today go further into detail but this should get your started. Make sure to change the nodes to your IP/Port.

{
“nodes”: [
{
“parameters”: {
“method”: “POST”,
“url”: “https://1.2.3.4:50000/b1s/v1/Login”,
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “{"UserName": "manager","Password": "Passw0rd", "CompanyDB": "Prod"}”,
“options”: {
“allowUnauthorizedCerts”: true,
“response”: {
“response”: {
“fullResponse”: true,
“neverError”: true
}
},
“timeout”: 5000
}
},
“id”: “5684bac0-37cf-4044-9544-cf3835556131”,
“name”: “Login to API”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
0,
0
]
},
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-220,
0
],
“id”: “906549a6-6ad6-40ba-b8ba-49763c969dfa”,
“name”: “When clicking ‘Test workflow’”
},
{
“parameters”: {
“url”: “=https://1.2.3.4:50000/b1s/v1/BusinessPartners(‘C00000’)”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Cookie”,
“value”: “={{ $(‘Login to API’).item.json.headers[‘set-cookie’][0] }}”
}
]
},
“options”: {
“allowUnauthorizedCerts”: true,
“response”: {
“response”: {
“fullResponse”: true,
“neverError”: true
}
},
“timeout”: 10000
}
},
“id”: “26fd7b06-bf7c-46f1-bf96-5d02dc13d37e”,
“name”: “Get Customer Data”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
220,
0
]
}
],
“connections”: {
“Login to API”: {
“main”: [
[
{
“node”: “Get Customer Data”,
“type”: “main”,
“index”: 0
}
]
]
},
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Login to API”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “d6bd811c736796576ede335615dd3f4400481cb03c3c930ae298eebd4b232405”
}
}

This is a link to their documentation but imho it’s severely lacking but it does give you a general idea of what you need. Service Layer API Reference

Let me know if you need more help.

Hmm, thought that would show you the actual workflow instead of the JSON. Must be a trick to paste it in. You should be able to import it though.

Thank you for sharing the workflow. I noticed that a new login occurs on each run, generating a fresh session cookie for subsequent requests. Most API systems prefer reusing a valid session cookie until it expires, which would be more efficient.

Have you considered implementing a subflow for authentication that could store and reuse the session cookie until expiration? This approach would reduce unnecessary authentication requests and align better with API best practices.