To post return orders into Microsoft Business Central the URL POST http://<serer name>:<odata port>/<service instance name>/api/BEterna/Import/v2.0/companies(<company system id>)/returnOrders
can be used.
It must be called with a JSON structure to create an order (webshopChannelCode is mandatory):
{
"webshopChannelCode": "B2B",
"subclient": "",
"customerIP": "",
"language": "DEU",
"testOrder": "0",
"orderId": "D-0000002",
"orderType": "2",
"orderDate": "2022-07-07 13:10:00",
"currency": "EUR",
"customerComment": "",
"customerNo": "C00010",
"registeredCustomer": "1",
"contactNo": "CT000023",
"returnOrderLines" : [
{
"id" : "10000",
"type" : "1",
"itemNumber" : "1900-S",
"variant" : "",
"amount" : "2",
"orderNo": "101008",
"orderLineNo": "10000",
"returnReason": "Storno",
"lineDescription" : "Desc1",
"lineDescription2" : "Desc2"
}
]
}
If a field is empty it can be left out in the JSON structure. The Return Header fields have the following meaning:
field | data type | content |
---|---|---|
webshopChannelCode |
Text[30] | Webshop Channel Code |
subclient |
Text[30] | the subclient who placed the order, actually not used |
customerIP |
Text[30] | IP address of the customer, actually not used |
language |
Text[3] | language code of the customer |
testOrder |
Text[30] | 0 or 1 , actually not used |
orderId |
Text[30] | distinct ID of the order |
orderType |
Text[30] | type of the order, type 2 is for return order |
orderDate |
Text[30] | order date and time in the form 2022-05-01 10:00:00 |
currency |
Text[30] | the ISO3 currency code of the order |
customerComment |
Text[80] | special customer comment for the order |
customerNo |
Text[20] | customer no. of the order, must be filled, even if the customer is new |
registeredCustomer |
Text[30] | 1 if the customer is registered and must exist, 0 if it is a guest order |
contactNo |
Text[20] | contact no. of the order, must be filled and exist |
There can be one or more Return Lines. They are transferred using a JSON array. The following fields can be defined for a single order line:
field | data type | content |
---|---|---|
id |
Integer | distinct identifier of the line in the order, must be distinct per order |
type |
Text[30] | must be one of the following values: 1 item line, 2 voucher sale, 3 discount, 4 shipping costs, 5 voucher cashing in, 6 payment costs, which values are possible depends on the setup of the webshop channel |
itemNumber |
Text[30] | the item number for item lines, must be empty otherwise |
variant |
Text[30] | optionally the item variant code for item lines, must be empty otherwise |
amount |
Text[30] | the quantity of the line for item lines, otherwise ist must always be 1 |
orderNo |
Text[30] | the order no. connected to posted sales document |
orderLineNo |
Text[30] | the order line no. in order document |
returnReason |
Text[30] | reason of returning order line |
lineDescription |
Text[250] | the first description of line |
lineDescription2 |
Text[250] | the second description of line |
The request is answered with a JSON structure containing all the header data that were transferred. If the answer should contain the transferred order lines as well, the $expand=returnOrderLines
can be attached to the URL and the answer contains the full order data that were transferred:
{
"@odata.context": "http://<server name>:<odata port>/<service tier name>/api/BEterna/Import/v2.0/$metadata#companies(<company system id>)/returnOrders/$entity",
"@odata.etag": "W/\"JzE5OzczMTc3ODQ0MzEzODk0ODgxMTIxOzAwOyc=\"",
"systemId": "a928cfd6-f7fd-ec11-be4d-a542e7ee7cff",
"webshopChannelCode": "B2B",
"subclient": "",
"customerIP": "",
"language": "DEU",
"testOrder": "0",
"orderId": "D-0000002",
"orderType": "2",
"orderDate": "2022-07-07 13:10:00",
"currency": "EUR",
"customerComment": "",
"customerNo": "C00010",
"registeredCustomer": "1",
"contactNo": "CT000023",
"returnOrderLines": [
{
"@odata.etag": "W/\"JzIwOzE1MjIyNDE3ODU0MjI0NzMwNTU0MTswMDsn\"",
"systemId": "aa28cfd6-f7fd-ec11-be4d-a542e7ee7cff",
"id": 10000,
"type": "1",
"itemNumber": "1900-S",
"variant": "",
"amount": "2",
"orderNo": "101008",
"orderLineNo": "10000",
"returnReason": "Storno",
"lineDescription": "Desc1",
"lineDescription2": "Desc2"
}
]
}