Interfaces - JSONPOST

Text only available in english

With the JSONPOST interface type, details of the selected item(s) are posted from the client (browser) to the URL specified via the hookUrl parameter.

After importing the items, the details of, for example, the article, can be retrieved using the web service "TradeItem/DetailsByGLNAndTradeItemIdA"

Interfaces

Article, Selection list, Product

Action POST the result to the specified hookUrl (fire-and-forget, no feedback within Unifeed), from the Client
Content 2BA JSON containing one or more articles
Example opening Unifeed https://unifeed.2ba.nl/?interfaceType=JSONPOST&interface=3&hookUrl=http://www.mycompany.com/receive2BA.aspx
Example response For articles and selection list:
[{
	"SupplierGLN":"8712423008724",
	"SupplierName":"Grundfos Nederland",
	"SuppliersTradeItemId":"97993195",
	"PricePerOrderUnit":"319.00",
	"Method":"OriginalGrossPrice",
	"Quantity":"2"
},{
	"SupplierGLN":"8711389000001",
	"SupplierName":"Technische Unie",
	"SuppliersTradeItemId":"1649593",
	"PricePerOrderUnit":"1.75",
	"Method":"DiscountArticlePercentage",
	"Quantity":"10"
}]
Voor product:
[{
	"ProductId":"56354b44-b01b-4f75-8ddf-c1defe1edf0b",
	"Description":"ALPHA2 25-40 130 1x230V 50Hz 6H"
}]

CORS

With the interfaceType=JSONPOST the POST is executed in the background from the client (browser).
Using this method, the customer remains on the current page in Unifeed. No navigation takes place.
The session, complete with all filters etc. remains intact.

A client-side post was chosed because it allows the use of internal/local IP addresses.
Another advantage is that this method (usually) does not require any firewall adjustments.

POSTing from the client, howerver, involves CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing).
The receiving application needs to accept the browser's POST.
This is achieved via a so-called preflight; First, an OPTIONS request is sent, specifying Unifeed as Origin.
The application should respond to this options request by suppliying an "Access-Control-Allow-Origin" header, containing the Unifeed website as specified in the OPTIONS request.
Only if this response makes it back to the browser will the true POST request take place.

Interface=JSON makes a direct POST, which does not involve CORS.

 

Testing using PostServer.com

By using "postserver.com", the post request can be tested easily:
https://unifeed.2ba.nl/?interfaceType=JSONPOST&interface=3&hookUrl=http://posttestserver.com/post.php?dir=EIGENCODE

After the post, the directory below will contain a file containing the contents of the POST.
http://posttestserver.com/data/2016/01/22/EIGENCODE (replace the date with today's date)

2BA B.V

Energieweg 3
3542 DZ Utrecht
+31 88 222 00 00
info@2ba.nl

Word lid van onze community