REST XML/Data Formatting for InterConnect
First published on: 08/10/2023/6:54 pm
InterConnect provides REST-based access to data in XML format, as well as select JSON-formatted data, via the B1WebAPI web service. Specifications for data formats are listed below.
In general, to access XML-based data content, simply access the object or query; XML is the default data type. You can also explicitly server XML content using the URL parameter accept=text/xml.
For example, http://myB1WebAPI.com/myProfile/object/edit/oOrders/1.aspx
and http://myB1WebAPI.com/myProfile/object/edit/oOrders/1.aspx?accept=application/json
will yield the same XML-based results.
To access JSON-based data, add the URL parameter accept=application/json to the URL. For example, http://myB1WebAPI.com/myProfile/object/edit/oOrders/1.aspx?accept=application/json
Object-specific XML for InterConnect
All object XML that is generated or received by the B1WebAPI web service must follow the XML representation of a DI-API object, as documented in the SAP Business One DI-API Objects Reference guide. As this guide covers the DI-API object model in great detail it will not be duplicated here.
A rule of thumb for understanding the DI-API XML for any object is to remember that public API properties are used to create the XML elements.
Query-specific Data for InterConnect
The B1WebAPI web service can return the results of a query from SAP Business One in three data formats: Default QueryData XML View; Default QueryData JSON View; Microsoft.NET DataSet View.
Default QueryData XML View
The Query data element is as follows:
<querydata xmlns:b1Link="http://www.zeditsolutions.com/v1.0/b1Link"
queryName="/query/[queryname].aspx?cardcode=[value]">
<columns></columns>
<data>
<row id="1"></row>
</data>
</querydata>
There are four major sections:
-
QueryData - This XML element is the main element that contains the other query-specific XML. It contains identifying information about the query used to execute the request.
-
Columns - This XML element contains a
Column
element for each Query Column specified in SAP Business One. It contains Meta Data information about the column including: name; alias; type; and a flag stating if it’s an internal key or not. -
Data - This XML element contains a
row
element for each query row that is returned from the SAP Business One query. -
Row - This XML element is created for each query row that is returned from the SAP Business One query and contains an XML element for each of the columns specified.
Default QueryData JSON View
Specifications are in progress. At a high level, JSON formatted query data contains the same data as in XML format.
Microsoft.NET DataSet View
The .NET DataSet XML representation of B1WebAPI web service XML is generally used for consumption by third-party .NET controls such as the DevExpress Grid or Pivot controls. As this XML is generated by the ADO.NET DataSet, the details are outside the scope of this document.
For the full details on the XML representation of an XML dataset, visit Microsoft’s official documentation: http://msdn.microsoft.com/en-us/library/zx8h06sz(v=VS.100).aspx
XML Envelope Format for InterConnect
Each B1WebAPI web service response from SAP Business One is contained within a common XML response envelope, as shown in the XML sample below.
<b1Reply:response requestType="schema" xmlns:b1Reply="http://www.zeditsolutions.com/2006/b1Reply">
<b1Reply:uri>/query/[query].aspx?param1=[value]&format=dataset</b1Reply:uri>
<b1Reply:status>OK</b1Reply:status>
<b1Reply:payload></b1Reply:payload>
<b1Reply:error />
</b1Reply:response>
There are four major sections:
- Uri - This contains the original URI call from the application that executed the original B1WebAPI web service request. In the example above we triggered this response via the query API.
- Status - The status field has 3 possible values that can be returned by the B1WebAPI web service:
- OK - indicates the data is fine as-is.
- ERROR - indicates the data has an error, as described by the error details below.
- NOT LICENSED - indicates that the request was terminated due to the application not being licensed. See Requesting and Installing a License for Portals for details on how to apply a license.
- Payload - The Payload element will contain the core XML of the query or object that was requested via the B1WebAPI web service.
- Error - If the status is ERROR, then this XML element will contain the details of the error messages returned from SAP Business One or the B1WebAPI web service.
Last modified: 11/13/2023/7:01 pm |