Data sources support sending of transaction data, which stores information about requests and changes of data source at a specific time period. Identification and saving of user request enable the user to process response if connection is lost.
TIP. Use sending of transaction data if caching is not set up.
Each transaction record is assigned with a unique request identifier that is transaction identifier. Uniqueness of transaction identifier generated by a mobile application is ensured by API user link and device in the project.
To use transaction identifier in data source requests, add the X-Transaction-ID header containing unique request identifier. The X-Transaction-ID header must correspond to the UUID standard.
NOTE. The X-Transaction-ID header is optional. If the connection is lost, and requests are executed without specifying parameter, the response contains an error message.
The example of data source request with the use of the X-Transaction-ID header (determine user token before executing the request):
curl "<IP address or DNS name of server>/api/v1/rpc/<name of data source resource>/" -X POST -v -H "Content-Type: application/json" -H "Authorization: Bearer <user token>" -H "X-Transaction-ID: <UUID>"
After the request is executed, the source data is obtained, and the request is added to transactions history.
All information about transactions (resource, user, mobile device identifier, request reception time, request processing state, response, request parameters) is stored in the transactions history. To avoid constant increase in mobile platform database size, clear transactions history manually or set a deletion schedule.
Algorithm of requests with transaction identifier:
The mobile application sends request to data source resource.
The data source gets the request and returns confirmation of successful execution of mobile platform server request.
If connection between server and mobile device is instable, on repeated request the mobile application specifies transaction identifier of the previous request to avoid repeated request execution in the data source.
A mobile platform server returns the message about successfully processed previous request and the response.
Transaction requests are given in the Method for Working with Transactions section.
See also: