Sample File Post Using cURL

This example uses cURL, a free open source command line tool, to send the HTTP request to post the data feed file to Guardian’s file service. Many Linux and Mac systems have this tool pre-installed. If you use Windows, the tool can be downloaded from (ensure your system meets the cURL requirements for SSL as the data will be transmitted over HTTPS). Please note, this tool is not specific to or supported by Guardian.

Your file should contain rows of data related to a specific data feed type. The cURL request will specify the data feed type that your file represents. The file is sent to the server in an HTTP POST request.

Authentication information is sent using the ‘-u’ command. This must be entered as user:password format. Since this is a file upload, the call utilizes cURL’s multipart/form formatting (-F). Utilizing the @ sign ensures the content to be a file. With this format, the response automatically defaults to the POST method. All information in the example is case sensitive. For example, using ‘-f’ rather than ‘-F’ will result in a different request.

Use a command line window to execute the following command:

curl -u client_id:client_secret -F ""guardian_datafeed=Employee"" -F ""content=@/path/to/file"" https://{file_service_hostname}/files/

client_id is the username provided to you by your implementation specialist

client_secret is the password provided to you by our implementation specialist

“guardian_datafeed=Employee” represents the data feed type that is being posted. The value after guardian_datafeed= must correspond to the file being uploaded and may be any of the supported data sets: Employee, User, Location, Group, or Custom Field.

content=@/path/to/file represents the file path of the file to be retrieved and submitted via the request; replace the contents after content=@ with the specific directory e.g. s:\guardian\datafeeds\employee. Tip: Consider creating a folder/path specific to each data feed type you will be implementing.

{file_service_hostname} represents the URI to direct the file. The hostname will be provided to you by your implementation specialist.

The file service returns a response. See the HTTP Status Code Response section for a list of possible responses.

Please note, the file service will not report file formatting errors. A successful response confirms that Guardian’s file service has received the request. Any errors in file formatting are reported in the result log that is available after the file is processed. File processing information, including success or error, is accessible within the Guardian application’s administration area and includes detailed information for each record/file row. Results are listed in numbered order. To compare results and/or troubleshoot errors, maintain the original data file and reference the file row number.