# Getting Log data using API

#### Introduction

This guide will walk you through fetching synchronization log data using the <mark style="color:blue;">/dbsync/api/getSyncLogsData</mark> endpoint. This API allows you to retrieve a summary and detailed statistics for database synchronization tasks based on a specific profile and date range.

***

#### Step 1: Prepare Your Request Details 📝

Before making the call, gather the necessary information.

* **Endpoint URL:** You'll need the base URL of the server where the API is hosted (e.g., <http://localhost:8080>). The full endpoint path is /dbsync/api/getSyncLogsData.
* **Authentication Credentials:** You must have a valid username and password.
* **Filters (Optional):** Decide if you want to filter the logs:
* **Profile Name:** The specific sync profile you're interested in (e.g., CRM\_SYNC).
* **Date Range:** A start date (fromDate) and an end date (toDate). Remember to use the **yyyy-MM-dd** format.

***

#### Step 2: Choose Your HTTP Method and Headers ⚙️

This endpoint requires a specific setup for the request.

* **Method:** You must use the POST method.
* **Headers:** Set the Content-Type header to application/x-www-form-urlencoded. This is crucial as the server expects form data, not JSON.

***

#### Step 3: Construct the Request Body ✍️

The body of your request will contain the parameters formatted as a URL-encoded string. All parameters are sent together, separated by an ampersand (&).

Add Authentication (Required):

1. **username**=`your_username`
2. **password**=`your_password`

Add Filters (Optional):

1. **profile**=`PROFILE_NAME`
2. **fromDate**=YYYY-MM-DD
3. **toDate**=YYYY-MM-DD

Example Body String: `username=admin&password=admin123&profile=CRM_SYNC&fromDate=2025-10-01&toDate=2025-10-17`

***

#### Step 4: Send the Request 🚀

You can now send the request using a tool like curl or Postman.

Using curl in a Terminal: Combine the URL, method, header, and body into a single command.

Bash

```bash
curl -X POST "http://<host>:<port>/dbsync/api/getSyncLogsData" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d
 "username=admin&password=admin123&profile=CRM_SYNC&fromDate=2025-10-01&toDate=2025-10-17"
```

&#x20;

Replace \<host>:\<port> with your server's actual address.

Using Postman:

1. Set the method to POST.
2. Enter the full request URL.
3. Go to the Body tab and select the x-www-form-urlencoded option.
4. Enter your parameters (e.g., username, password, profile) in the key-value editor.
5. Click Send.

<figure><img src="https://1807783010-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrJ01SyijpwGkw5NZTFOA%2Fuploads%2F59rw9NycLdA8JeiLVrKr%2Funknown.png?alt=media&#x26;token=f6a4ec73-c589-4622-a3b2-8bded4d85814" alt=""><figcaption></figcaption></figure>

***

#### Step 5: Interpret the Response 📊

After sending the request, you'll receive a JSON response.

If Successful (Status 200 OK): The response will contain a data object with two main parts:

* **syncs:** A detailed list of individual synchronization jobs that ran within the specified date range.
* **Summary:** An aggregated overview, including the total number of syncs, successes, errors, and records processed.

```json
JSON
{
    "message": "Login successful",
    "data": {
        "profiles": [
            {
                "profileName": "KCSFullSandboxToIntlDavMySQL",
                "individualSyncs": [
                    {
                        "id": 2724,
                        "runStatus": "completed",
                        "totalRecords": 200882,
                        "totalRecordsWritten": 200882,
                        "startDateTime": "2025-04-10 23:00:07.394",
                        "completedDateTime": "2025-04-10 23:09:21.597",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2722,
                        "runStatus": "completed",
                        "totalRecords": 200732,
                        "totalRecordsWritten": 200732,
                        "startDateTime": "2025-04-10 21:00:05.581",
                        "completedDateTime": "2025-04-10 21:09:24.815",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2720,
                        "runStatus": "completed",
                        "totalRecords": 200653,
                        "totalRecordsWritten": 200653,
                        "startDateTime": "2025-04-10 19:00:06.352",
                        "completedDateTime": "2025-04-10 19:09:25.549",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2718,
                        "runStatus": "completed",
                        "totalRecords": 200692,
                        "totalRecordsWritten": 200692,
                        "startDateTime": "2025-04-10 17:00:06.612",
                        "completedDateTime": "2025-04-10 17:09:56.814",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2716,
                        "runStatus": "completed",
                        "totalRecords": 200581,
                        "totalRecordsWritten": 200581,
                        "startDateTime": "2025-04-10 15:00:07.763",
                        "completedDateTime": "2025-04-10 15:10:14.964",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2714,
                        "runStatus": "completed",
                        "totalRecords": 201036,
                        "totalRecordsWritten": 201036,
                        "startDateTime": "2025-04-10 13:00:06.89",
                        "completedDateTime": "2025-04-10 13:10:39.073",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2712,
                        "runStatus": "completed",
                        "totalRecords": 200928,
                        "totalRecordsWritten": 200928,
                        "startDateTime": "2025-04-10 11:00:07.118",
                        "completedDateTime": "2025-04-10 11:10:36.365",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2710,
                        "runStatus": "completed",
                        "totalRecords": 200821,
                        "totalRecordsWritten": 200821,
                        "startDateTime": "2025-04-10 09:00:08.817",
                        "completedDateTime": "2025-04-10 09:09:53.013",
                        "erroredObjects": [
                        ]
                    }
                ],
                "consolidatedData": {
                    "totalSyncs": 8,
                    "completedCount": 8,
                    "erroredCount": 0,
                    "inProgressCount": 0,
                    "totalRecords": 1606325,
                    "totalRecordsWritten": 1606325,
                    "successRate": 100.0,
                    "allErroredObjects": [
                    ]
                }
            },
            {
                "profileName": "KCSFullSandboxToIntlDavSnowflake",
                "individualSyncs": [
                    {
                        "id": 2723,
                        "runStatus": "completed",
                        "totalRecords": 200915,
                        "totalRecordsWritten": 200915,
                        "startDateTime": "2025-04-10 22:00:05.632",
                        "completedDateTime": "2025-04-10 22:09:23.851",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2721,
                        "runStatus": "completed",
                        "totalRecords": 200639,
                        "totalRecordsWritten": 200639,
                        "startDateTime": "2025-04-10 20:00:08.525",
                        "completedDateTime": "2025-04-10 20:09:24.772",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2719,
                        "runStatus": "completed",
                        "totalRecords": 200666,
                        "totalRecordsWritten": 200666,
                        "startDateTime": "2025-04-10 18:00:06.202",
                        "completedDateTime": "2025-04-10 18:09:25.427",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2717,
                        "runStatus": "completed",
                        "totalRecords": 200556,
                        "totalRecordsWritten": 200556,
                        "startDateTime": "2025-04-10 16:00:07.147",
                        "completedDateTime": "2025-04-10 16:10:12.745",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2715,
                        "runStatus": "completed",
                        "totalRecords": 200646,
                        "totalRecordsWritten": 200646,
                        "startDateTime": "2025-04-10 14:00:06.123",
                        "completedDateTime": "2025-04-10 14:10:25.372",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2713,
                        "runStatus": "completed",
                        "totalRecords": 200793,
                        "totalRecordsWritten": 200793,
                        "startDateTime": "2025-04-10 12:00:08.469",
                        "completedDateTime": "2025-04-10 12:09:51.66",
                        "erroredObjects": [
                        ]
                    },
                    {
                        "id": 2711,
                        "runStatus": "completed",
                        "totalRecords": 200814,
                        "totalRecordsWritten": 200814,
                        "startDateTime": "2025-04-10 10:00:08.042",
                        "completedDateTime": "2025-04-10 10:10:17.268",
                        "erroredObjects": [
                        ]
                    }
                ],
                "consolidatedData": {
                    "totalSyncs": 7,
                    "completedCount": 7,
                    "erroredCount": 0,
                    "inProgressCount": 0,
                    "totalRecords": 1405029,
                    "totalRecordsWritten": 1405029,
                    "successRate": 100.0,
                    "allErroredObjects": [
                    ]
                }
            }
        ],
        "metadata": {
            "fromDate": "2025-04-10T00:00:00",
            "toDate": "2025-04-10T23:59:59",
            "profileFilter": "All profiles",
            "generatedAt": "2025-09-30T17:16:33.6550391"
        }
    }
}
```

If Unsuccessful (Error): Check the HTTP status code to understand the problem:

* **400 Bad Request:** You forgot to include the username or password.
* **401 Unauthorized:** Your username or password was incorrect.
* **500 Internal Server Error:** A problem occurred on the server. Contact the administrator.

#### Notes

* The endpoint consumes form-urlencoded data for the request body, not JSON. This is often done for compatibility with standard HTML form submissions.
* The log data is generated dynamically by the DBProcessLogAdapter, which queries the database for statistics in real-time.
* All date and time fields in the response are based on the Asia/Kolkata time zone ($UTC+05:30$).
* Authentication is sessionless. You must send the username and password with every single request.

#### Test in Postman

You can easily test this endpoint using an API client like Postman.

1. Open Postman and create a new request.
2. Set the HTTP method to POST.
3. Enter the full request URL: <http://localhost:8080/dbsync/api/getSyncLogsData>
4. Go to the Body tab and select the x-www-form-urlencoded option.
5. Add the following key-value pairs:
6. username: your username
7. password: your password
8. profile: desired sync profile (optional)
9. fromDate: e.g., 2025-10-01
10. toDate: e.g., 2025-10-17
11. Click the Send button to execute the request and see the JSON response.

#### Example Use Case

Imagine you need to view the synchronization logs for the Salesforce-to-DB2 profile from October 1 to 17, 2025.

* Username: `dbsync_admin`
* Password: `secret@123`
* Profile: `SF2DB2`
* URL: <mark style="color:green;"><http://localhost:8080/dbsync/api/getSyncLogsData></mark>

Making a POST request with these parameters will return a JSON object containing both the aggregated success/error metrics and a detailed list of all sync jobs for that specific profile and date range.

<br>
