# Bulk Data Upload The Bulk Data Upload feature, available both via API and UI, enables users to upload and manage bulk data files efficiently. Users need to: * create a BULK_UPLOAD_HISTORY record * upload files * optionally, retrieve successful or rejected records. ## Creating a new record The first step in the process of uploading a bulk data file is to create a record in the BULK_UPLOAD_HISTORY table. ### Request body `URL: https://my.billingplatform.com/rest/2.1/bulk_upload_history` Method: POST ```json { "brmObjects": [ { "ActivityCollectorId": " " } ] } ``` * `ActivityCollectorId`: The ID of the BULK_DATA_LOADER for which the bulk upload record is being created. ### Example request ```curl curl -X POST https://my.billingplatform.com/rest/2.1/bulk_upload_history \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-access-token" \ -d '{ "brmObjects": [ { "ActivityCollectorId": "848" } ] }' ``` ### Example response ```json { "createResponse": [ { "ErrorCode": "0", "ErrorText": "", "ErrorElementField": "", "Id": "7509" } ] } ``` * `Id`: The ID of the created BULK_UPLOAD_HISTORY record. This value will be used in the next step to upload the actual file associated with the bulk data upload. Upon successful creation of the record, it will appear in the UI with the status `AWAITING_FILE`. This indicates that the system is ready to receive the associated file for this bulk upload. ## Uploading a file After creating a BULK_UPLOAD_HISTORY record, the next step is to upload the actual file to this record using the API. The file data must be encoded in Base64 format. ### Request body `URL: https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/{recordId}/AllRecordsFile` * `{recordId}`: Replace this with the ID of the BULK_UPLOAD_HISTORY record created in the previous step. Method: POST ```json { "Id": " ", "EntityName": "BULK_UPLOAD_HISTORY", "FileName": " ", "FieldName": "AllRecordsFile", "Data": " " } ``` * `Id`: The ID of the BULK_UPLOAD_HISTORY record to which the file is being uploaded. * `FileName`: The name of the file being uploaded. * `Data`: The content of the file, encoded in Base64. ### Example request ```curl curl -X POST https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/7509/AllRecordsFile \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-access-token" \ -d '{ "Id": "7509", "EntityName": "BULK_UPLOAD_HISTORY", "FileName": "Bulk Upload 7509 2.csv", "FieldName": "AllRecordsFile", "Data": "SWQsTk1CReXJZXh0LE5NQkRMTnVtYmVyLE5NQkRMQ2h1Y2sNCixUZ... (Base64 string truncated)" }' ``` ## Example response ```json { "fileUploadResponse": [ { "ErrorCode": "0", "ErrorText": "", "ErrorElementField": "" } ] } ``` Upon successful upload of the file data, the status of the BULK_UPLOAD_HISTORY record changes to `PENDING`, indicating that the file is now ready for further processing. ## Retrieving successful records After successfully uploading the file to the BULK_UPLOAD_HISTORY record, you can view the uploaded data using a GET request. This step allows you to retrieve the file content that was uploaded and associated with the record. ### Request body `URL: https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/{recordId}/SuccessRecordsFile` * `{recordId}`: Replace this with the ID of the BULK_UPLOAD_HISTORY record you want to view. Method: GET ### Example request ```curl curl -X GET https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/7509/SuccessRecordsFile \ -H "Authorization: Bearer your-access-token" ``` ### Example response ```json { "fileDownloadResponse": [ { "ErrorCode": "0", "ErrorText": "", "ErrorElementField": "", "FileName": "BULK_UPLOAD_SUCCESS-7509 2.csv", "Data": "SWQsTk1CReXJZXh0LE5NQkRMTnVtYmVyLE5NQkRMQ2h1Y2sRCRE... (Base64 string truncated)" } ] } ``` * `FileName`: The name of the file that was successfully uploaded and is now being retrieved. * `Data`: The content of the file, encoded in Base64. To view the content, you will need to decode this Base64 string. ## Retrieving rejected records You can also view any rejected records using a GET request. ### Request body `URL: https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/{recordId}/RejectedRecordsFile` * `{recordId}`: Replace this with the ID of the BULK_UPLOAD_HISTORY record you want to view. Method: GET ### Example request ```curl curl -X GET https://my.billingplatform.com/rest/2.0/files/BULK_UPLOAD_HISTORY/7509/RejectedRecordsFile \ -H "Authorization: Bearer your-access-token" ``` ### Example response ```json { "fileDownloadResponse": [ { "ErrorCode": "0", "ErrorText": "", "ErrorElementField": "", "FileName": "BULK_UPLOAD_REJECT-7509 2.csv", "Data": "SWQsTk1CReXJZXh0LE5NQkRMTnVtYmVyLE5NQkRMQ2h1Y2sRCRE... (Base64 string truncated)" } ] } ``` * `FileName`: The name of the file containing rejected records. * `Data`: The content of the rejected file, encoded in Base64. To view the content, decode this Base64 string.