The following example describes how to make a request to an API to generate a report. The API supports GET requests and requires specific parameters to generate the report. The request is made to a specific URL, which depends on the server hosting the client application.
Note on the URL
The URL used to call the API, such as, for example rdp103.sbzsystems.com
, depends on the server that hosts the client’s application. Therefore, this part of the URL will vary depending on the environment where the client is hosted. The client should use the appropriate URL assigned to their server to ensure the request works correctly.
Request Method
The API call is made using the GET method. The request’s format requires providing specific parameters in the URL, which determine the data that will be retrieved.
API URL
The request is made to the following URL:
1 |
https://[client-server]/apps/createreport.aspx |
Where [client-server]
represents the server hosting the client’s application.
Parameters
The parameters appended to the URL are as follows:
from
: Specifies the start date and time for the data to be retrieved, in the formatYYYYMMDDHHMMSS
. For example,from=20240101000000
refers to January 1, 2024, at 00:00:00.to
: Specifies the end date and time for the data, also in theYYYYMMDDHHMMSS
format. For example,to=20240901000000
refers to September 1, 2024, at 00:00:00.user
: The username used for authentication with the API. For example,user=testuser
.q
: Specifies the title of report requested. In this example,q=00.orders
refers to reports related to orders.key
: A security key required for accessing the API. This key is set via EMDI’s settings, Communication/Maintenance, Communication via http Code/ID.format
: The format in which the data will be returned. In this example, the value isjson
, meaning the data will be returned in JSON format. It should be noted that the report will need to be designed accordingly, for the result to be valid.
Example Request
The complete API call with the above parameters might look like this:
1 |
https://[client-server]/apps/createreport.aspx?from=20240101000000&to=20240901000000&user=testuser&q=00.orders&key=123&format=json |
This URL includes all the necessary information to generate a report for the period from January 1, 2024, to September 1, 2024, for the user “testuser,” with a focus on orders, and will return the data in JSON format.
Response
The API will return a report in the requested format, such as JSON, which can be parsed and used by the system or application.
Code Example
The following code demonstrates how to make the API request and handle the response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://[client-server]/apps/createreport.aspx?from=20240101000000&to=20240901000000&user=testuser&q=00.orders&key=123&format=json', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response; |
Note: Replace [client-server]
with the correct server URL for the client’s environment to ensure the API functions correctly.