The SAP Business One Service Layer is a Web API that allows external applications to interact with SAP Business One data.
Netronic Manufacturing uses the Service Layer to integrate with SAP Business One. Therefore, for Netronic Manufacturing to operate properly, it is mandatory that the SAP Service Layer is configured correctly and that all requests sent to it are executed as expected.
Make sure you use Version 1 of the SAP Business One Service Layer. Version 2 is currently not supported and its use may cause issues.
SAP Support have published a note that contains
- the parameters to be collected and considered for your Service Layer configuration,
- guidelines for the hardware, and
- guidelines for the implementation.
As the above note points out, it is recommended to restart the Service Layer and System Landscape Directory (SLD) services regularly, at least once a day, in order to maintain smooth connection.
For better performance, you may also want to set the MaxConnectionsPerChild value to 0 and thus set no limit.
For an easy first check to find out whether your application(s) communicate properly with SAP Business One, see How to test quickly if synchronization works between Netronic Manufacturing and SAP Business One.
It can happen that Netronic Manufacturing fails to connect to SAP Business One using the SAP Service Layer for reasons that are outside of Boyum’s control. The requests that Netronic Manufacturing sends to the SAP Service Layer can return errors for various reasons.
Therefore, when Netronic Manufacturing fails to connect to or to perform operations in SAP Business One, an important troubleshooting step will be to try to perform the same operation with the SAP Service Layer without using Netronic Manufacturing. If the operation fails this way as well, then the root cause of the problem is most likely located in the SAP Service Layer or the SAP Business One configuration.
Using Postman to check connection with the SAP Service Layer
We recommend using Postman as the main tool to send requests to the SAP Service Layer. Postman is a popular and free tool that can be downloaded from https://www.postman.com/.
Self-signed SSL certificates and Postman
With the default settings (shown in the screenshot below), Postman does not allow to connect to servers using a self-signed SSL certificate.
The first time you try to connect to a server using a self-signed SSL certificate, Postman will display an error message in the response, and the error message contains a link that automatically changes the setting to allow these requests.
Service Layer URL
The SAP Business One Service Layer is accessible from a URL that can be either a domain name or an IP address, followed by a port number.
Typically, the SAP Service Layer will be accessible through different URLs depending on if it is accessed from inside the same network (like from another machine in the same site) or from an external network (like Netronic Manufacturing). Please bear this in mind when configuring the connection to the SAP Service Layer.
At the end of the URL, the port number of the SAP Service Layer should be appended. By default, it is port 50000.
A full SAP Service Layer URL looks like this: 192.168.25.29:50000
Login
When communicating with the SAP Service Layer, the first step should always be to login.
This can be done with Postman as follows:
- Method: POST
- Request URL: https://<servicelayerurl>/b1s/v1/Login
- Body: raw
- Body content:
{ "CompanyDB": "MYDATABASE", "UserName": "manager", "Password": "123password" }
The UserName and Password values should be the exact same values as the ones used to login to the SAP Business One Client. For example, in the case of a cloud-hosted SAP Business One, users typically need to use Windows credentials to login, like this:
or this:
After pressing the Send button, you should see a response like the one below if the login was successful:
If you entered a wrong password, then you will get a response similar to this:
Perform operations
After a successful login, Postman is authenticated on the SAP Service Layer with the given credentials, and all subsequent requests are performed using this session.
The details of a request sent to the SAP Service Layer greatly depend on the operation that needs to be performed. You will typically receive instructions from the technical support team regarding the parameters to use.
Example 1: Get a list of items
- Method: GET
- Request URL: https://<servicelayerurl>/b1s/v1/Items
- Body: none
After pressing the Send button, you should see a response like the one below if the request was performed successfully:
Example 2: Close production order
- Method: PATCH
- Request URL: https://<servicelayerurl>/b1s/v1/ProductionOrders(<productionorderkey>)
- Body: raw
- Body content:
{ "ProductionOrderStatus": "boposClosed" }
After pressing the Send button, you should see a response like the one below if the request was performed successfully:
Example 3: Batch request
In the SAP Service Layer, a batch request is a single request that performs multiple operations in a single transaction. If one of the operations fails, then the complete batch is rolled back and cancelled.
- Method: POST
- Request URL: https://<servicelayerurl>/b1s/v1/$batch
- Body: raw
- Body content: (depends on the operations to be performed)
Additionally, the Content-Type header needs to be set manually before sending the request. First, you should deactivate the existing Content-Type header. Then you should add a new line at the end of the headers list, with the name Content-Type, and the following value:
multipart/mixed; boundary=batch_e144de91-a0ef-4604-be34-813049278e50
where batch_e144de91-a0ef-4604-be34-813049278e50 matches the first line of the request’s body:
After pressing the Send button, you should see a response like the one below:
If the batch request was formatted correctly, then the response should have the status 202 Accepted.
In order to determine if the operation was performed successfully, you should look at the content of the response. The response includes the individual results of all the parts of the batch request, and you can see if each part has succeeded or failed based on the response’s details.
Here is an example of a failed result:
Comments
0 comments
Please sign in to leave a comment.