Using a batch file to automate uploads with cURL


Once you have been able to successfully upload data files into your PrecisionLender account, you may decide to automate the upload of these files on a scheduled basis.  This article outlines the steps to be completed to create a batch file for uploads via cUrl.

Step-by-Step Guide 

  1. Prepare your file in the correct format required by the API endpoint. All of which are detailed within the PrecisionLender API documentation (API v2-> Assumptions).
  2. Install cUrl on the machine or server you wish to use to upload the files to PrecisionLender. Details for downloading cUrl and further documentation are available within the cUrl library.
  3. In order to use the PrecisionLender API, at least one Service User account will need to be setup and enabled. Follow steps available within the Service User Account Access For PrecisionLender API support article to complete service user setup.
  4. After setting up your service user, replace the credentials in the sample cURL script below with your own, and specify the file path.
  5. This batch file can then be executed either manually by double clicking, or by setting up an automated task using Windows Task Scheduler.

Sample Batch File 

:: Enter your credentials here:
set serviceUserName=<ServiceUserName>
set serviceUserKey=<ServiceUserKey>
set clientId=<ServiceUserKey>
:: Enter the location of the folder containing your files here:
set FilePath=\\fileserver\shared folders\Precision Lender\Funding Curves
set FileFC=sample_curve_data.txt
:: Nothing below this line should need to be changed
set URLFC=
:: Upload the funding curve data
curl --request PATCH \
--url \
-H 'Authorization: Basic %serviceUserName%:%ServiceUserKey%' \
-H 'ClientId: %clientId%' \
-F file=@"%FilePath%\%FileFC%"

Related Articles: