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"
}]
For product:
[{
"ProductId":"56354b44-b01b-4f75-8ddf-c1defe1edf0b",
"Description":"ALPHA2 25-40 130 1x230V 50Hz 6H"
}]
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.
To use the JSONPOST, the receiving server must have CORS enabled and your URL(s) specified at 2BA in Policies:connect-src and frame-ancestors. By using ” webhook.site “, the post request can be tested easily, example URL:
https://unifeed.2ba.nl/?interfaceType=JSONPOST&interface=3&hookUrl=https://webhook.site/88b15f6f-12a6-4df0-8a09-f0cb6c0085d2/?list_a=DATE
After the post, the directory below will contain a file containing the contents of the POST.
https://webhook.site/#!/88b15f6f-12a6-4df0-8a09-f0cb6c0085d2