This documentation provides guidance on using the CMRSoftware API. The CMRSoftware API is a RESTful web service that enables the creation, modification, and listing of CMR consignment notes. The CMRSoftware API offers endpoint for performing various operations. The endpoint is accessible through HTTP methods and returns responses in JSON or XML format.
The documentation includes:
Authentication process
Description and usage of endpoints
Request and response samples
Error messages and their handling
Technical requirements and examples are also provided to facilitate easy integration of the CMRSoftware API into your applications.
To use the CMRSoftware API, each request must be authenticated. The authentication process is as follows:
Token-Based Authentication: Each request requires a valid API token, which must be sent in the HTTP headers.
Unique Request ID: Optionally, a unique request ID can be sent in the headers to help track requests.
The API token can be found on the API dashboard page.
If needed, a new token can be generated using the Regenerate button, but the token in the header must be updated accordingly.
It can be configured to accept requests from all IP addresses or only from specified IP addresses.
Copy✅ |
|
Authorization:
The Bearer {YOUR_API_TOKEN}
header provides authentication.
Content-Type: The
request and response format can be application/json
or application/xml
.
X-Request-ID: (Optional) A unique identifier to help track requests.
Each response is authenticated based on the token provided in the
Authorization
header and will be in the
format specified by the Content-Type
header.
The structure of requests and responses in JSON and XML is the same (except for the XML root element). A request consists of two parts: the header part containing the operation and the request part containing the sent data.
Copy✅ |
|
Copy✅ |
|
The operation
tag in the header can
have the following values:
create
:
To create a new CMR waybill.
preview
:
To preview a CMR waybill.
draft
:
To save a CMR waybill as a draft.
modify
:
To modify an existing draft CMR waybill.
finalize
:
To finalize a CMR waybill.
download
:
To download CMR waybill.
getdata
:
To retrieve data for a specific CMR waybill.
Each request must include the appropriate operation value in the
header and the relevant data in the request body. The response will
be the same format specified in the Content-Type
header of the request.
Operation |
XSD and XML/JSON example |
Description |
Same feature on CMRSoftware Online |
create |
Create PDF CMR waybill. No longer possible to modify |
New CMR waybill → Save & Print |
|
preview |
PDF Preview without serial number |
New CMR waybill → Preview |
|
draft |
Create a draft waybill with serial number |
New CMR waybill → Save |
|
modify |
Data update on draft |
Edit -> Save |
|
finalize |
Finalize and close a draft and create a PDF CMR waybill. No longer possible to modify |
Edit → Save &Print |
|
list |
List of CMR Waybills |
History |
|
download |
Download a PDF CMR Waybill |
History → Print |
|
getdata |
Data of the specified waybill |
History → Load as new (Clone) |
modify, finalize all data must be resubmitted, if a field is not submitted, it will be empty.
create, preview, draft, modify, finalize
Field no. |
Field |
JSON / XML markup |
Type |
Mandatory |
1 |
Sender (name, address, country) |
sender |
string |
|
2 |
Consignee (name, address, country) |
consignee |
string |
|
3 |
Place of delivery of the goods (place, country) |
place_of_delivery |
string |
|
4 |
Place of taking over the goods (place, country, date) |
loading_place |
string |
|
4 |
Date of taking over the goods |
loading_date |
date YYYY-MM-DD |
|
5 |
Annexed documents |
annexed_documents |
string |
|
6 |
Marks and numbers |
marks_and_numbers |
normalizedString |
|
7 |
Number of packages |
number_of_packages |
integer |
|
8 |
Method of packing |
method_of_packing |
normalizedString |
|
9 |
Nature of the goods |
nature_of_the_goods |
normalizedString |
|
10 |
Statistical number |
statistical_number |
normalizedString |
|
11 |
Gross weight kg |
weight |
float(11,3) |
|
12 |
Volume m3 |
volume |
float(11,3) |
|
13 |
Sender's instructions (Customs and other formalities) |
senders_instructions |
string |
|
14 |
Directions as to freight payment |
freight_payment |
string |
|
14 |
Freight paid |
freight_paid |
boolean |
|
14 |
Freight to be paid |
freight_to_be_paid |
boolean |
|
16 |
Carrier (name, address, country) |
carrier |
string |
|
17 |
Successive carriers (name, address, country) |
successive_carriers |
string |
|
18 |
Carrier's reservations and obserations |
carriers_reservations_and_obserations |
string |
|
19 |
Special agreements |
special_agreements |
string |
|
21 |
Established in |
established |
normalizedString |
|
21 |
Established on |
established_date |
date YYYY-MM-DD |
|
22 |
Signature and stamp of the sender |
signature_sender |
base64 encoded jpg image |
|
23 |
Signature and stamp of the carrier |
signature_carrier |
base64 encoded jpg image |
|
|
Class |
class |
normalizedString |
|
|
Number |
number |
normalizedString |
|
|
Letter |
letter |
normalizedString |
|
|
ADR |
adr |
normalizedString |
|
16 |
Tractor license plate |
tractor_license_plate |
normalizedString |
|
16 |
Trailer license plate |
trailer_license_plate |
normalizedString |
|
|
ISO 639-1 Language Code 1 |
lang1 |
enum ("bg", "cs", "de", "en", "es", "fi", "fr", "hu", "it", "nl", "pl", "ro", "sk","sr") |
* |
|
ISO 639-1 Language Code 2 |
lang2 |
enum ("bg", "cs", "de", "en", "es", "fi", "fr", "hu", "it", "nl", "pl", "ro", "sk","sr") |
* |
25 |
Custom field 1 |
cmr25_custom_name |
normalizedString |
|
26 |
Custom field 2 |
cmr26_custom_name |
normalizedString |
|
25 |
Custom field 1 value |
cmr25_custom_value |
string |
|
26 |
Custom field 2 value |
cmr26_custom_value |
string |
|
|
Copy for the Sender |
copy_sender |
Integer minInclusive = 0 maxInclusive = 8 |
* |
|
Copy for the Carrier |
copy_carrier |
Integer minInclusive = 0 maxInclusive = 8 |
* |
|
Copy for the Consignee |
copy_consignee |
Integer minInclusive = 0 maxInclusive = 8 |
* |
|
Copies |
copies |
Integer minInclusive = 0 maxInclusive = 8 |
* |
22 |
Signature and stamp of the sender |
stamp_sender |
Base64 encoded JPEG image |
|
23 |
Signature and stamp of the carrier |
stamp_carrier |
Base64 encoded JPEG image |
|
list
No data.
download, getdata
Serial (string)
The response header part includes the operation, the request ID, and the result of the operation. In the result part, it contains the result corresponding to the request or, if the operation failed, the error message.
Copy✅ |
|
Copy✅ |
|
Operation | Respopnse |
create, finalize, download
|
Serial and a base64 encoded PDF waybill |
draft, modify
|
Serial and base64 encoded PDF waybill preview |
preview
|
Base64 encoded PDF waybill preview |
Copy✅ |
|
Copy✅ |
|
In the above examples:
header: Contains metadata about the request.
operation: The operation that was performed.
requestId: The
unique request ID that was sent with the request (X-Request-ID:
{UNIQUE_REQUEST_ID}
).
status: The
status of the operation (success
or
error
).
response: Contains the result of the request.
result: The data resulting from the request or an error message if the operation failed.
Error messages returned by the API can be tracked on the API Log page. Here, you can view both the request and the response, including any error messages. The logged information is useful for diagnosing and addressing potential issues.
Sandbox error messages can be tracked on the Sandbox Log page.
View Requests and Responses: Every API call is logged with both the request and the response, including any error messages.
Filter by Operation Types: Logged entries can be filtered by operation types, making it easy to locate errors related to specific operations.
This section enables quick identification of errors and allows for necessary corrections by providing detailed tracking of the API calls.
Copy✅ |
|
-X POST: Specifies the HTTP method as POST.
https://www.cmrsoftware.com/api/: The URL endpoint of the API.
-H "Authorization: Bearer {YOUR_API_TOKEN}": The authorization header with your API token.
-H "Content-Type: application/xml": Specifies that the content type is XML.
-H "X-Request-ID: {YOUR_UNIQUE_REQUEST_ID}": (Optional) Includes a unique request ID for tracking purposes.
--data-binary "@path/to/your/file.xml":
Sends the contents of the XML file located at path/to/your/cmr.xml
.
Replace {YOUR_API_TOKEN}
,
{YOUR_UNIQUE_REQUEST_ID}
, and the file path
with your actual values. This command will send the XML file as the
body of the POST request to the specified API endpoint.
This section outlines how to send an API request in SAP, handle the response, and save a Base64-encoded PDF file from the response as a binary file on the server.
Copy✅ |
|
XML Request Preparation:
Load the XML data to be sent in the lv_xml_data
variable.
HTTP Client Creation:
Create the HTTP client using the cl_http_client=>create_by_url
method.
Setting HTTP Headers: Set the required headers, including Authorization, Content-Type, and X-Request-ID.
Sending the Request: The XML data is sent as part of a POST request.
Receiving the Response:
The API response is captured in lv_xml_response
.
Parsing the XML Response:
The response is parsed using the cl_ixml
interface, and the Base64 encoded PDF is extracted.
Decoding the Base64 PDF:
Use the SCMS_BASE64_DECODE_STR
function
module to decode the Base64 string into an xstring
.
Saving the PDF File: Finally, the decoded
PDF is written to a file using the OPEN
DATASET
and TRANSFER
statements.
Replace the placeholders such as
{YOUR_API_TOKEN}
, {YOUR_UNIQUE_REQUEST_ID}
,
and the file paths with actual values.
The SCMS_BASE64_DECODE_STR
function module is used to decode the Base64 encoded data.
The cl_ixml
interface is
utilized for parsing the XML document to extract the relevant
information.
This process outlines how to execute an API request, handle the response, decode a Base64 encoded PDF, and save it as a file within an SAP environment using ABAP.
Here’s a Python example demonstrating how to send a request to
the API, process the response, decode the Base64 encoded PDF, and
save it to a file named CMR serial
.pdf.
Copy✅ |
|
API Endpoint and Headers:
Set the url
to the API endpoint.
Define the headers, including the
Authorization
token, Content-Type
,
and a unique X-Request-ID
.
Sending the POST Request:
Use the requests.post()
method to send the request to the API endpoint.
Processing the Response:
Check if the response status is 200 (successful).
Parse the JSON response to
extract the serial
number and the
Base64 encoded PDF.
Decoding and Saving the PDF:
Decode the Base64 encoded PDF
using base64.b64decode()
.
Create the file name using the
extracted serial
number.
Write the decoded PDF data to a
file using the with open()
context
manager in binary mode (wb
).