Skip to main content

Upload via API

Description.

This guide explains how to upload your scan file using APIs.

As a reminder:

Example of use.

In these examples, we'll use the curl command, available natively on Mac and Linux.

Connection.

First, you'll need to generate a token to use the :

curl -X 'GET' \
https://ftp.hipli.pro/api/v2/user/token
-H 'accept: application/json' \
-H 'authorization: basic bG9naW46cGFzc3dvcmQ='

The username:password pair must be encoded in base64 and passed in the authorization header of the request.

Example:

  • username = "login"
  • password = "password"

This gives: login:password, then base64("login:password") = "bG9naW46cGFzc3dvcmQ="

If you want to encode or understand how base64 works: https://www.base64encode.org/

This first step will retrieve an access token and an expiration date:

{
"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJVXNlciIsIjE3Mi4yMC4wLjEiXSwiZXhwIjoxNzA2NjQ5MDQ4LCJqdGkiOiJjbXNtMmE0djVvcnM3M2Z1bjA0MCIsIm5iZiI6MTcwNjY0NzgxOCwicGVybWlzc2lvbnMiOlsicGFzc3dvcmQtY2hhbmdlLWRpc2FibGVkIiwicGFzc3dvcmQtcmVzZXQtZGlzYWJsZWQiLCJwdWJsaWNrZXktY2hhbmdlLWRpc2FibGVkIiwibWZhLWRpc2FibGVkIiwiYXBpLWtleS1hdXRoLWNoYW5nZS1kaXNhYmxlZCIsImluZm8tY2hhbmdlLWRpc2FibGVkIiwic2hhcmVzLWRpc2FibGVkIiwic2hhcmVzLXdpdGhvdXQtcGFzc3dvcmQtZGlzYWJsZWQiXSwic3ViIjoiMTcwNjYyNTQ3MDM1MyIsInVzZXJuYW1lIjoiemlkd2NqcXBzd21xMHQzczd1c3M3dG5wIn0.Bki_Ub4jV58zI2RRQRH8xC507p6wJc9CCM8EWixRX00",
"expires_at":"2024-01-30T21:10:48Z"
}

This is the token to be used in the following call.

File upload.

Go to the directory containing the file to be sent and execute the following command:

curl -X 'POST' \
'https://ftp.hipli.pro/api/v2/user/files' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJVXNlciIsIjE3Mi4yMC4wLjEiXSwiZXhwIjoxNzA2NjQ4OTQ4LCJqdGkiOiJjbXNtMWg0djVvcnM3M2Z1bjAzMCIsIm5iZiI6MTcwNjY0NzcxOCwicGVybWlzc2lvbnMiOlsicGFzc3dvcmQtY2hhbmdlLWRpc2FibGVkIiwicGFzc3dvcmQtcmVzZXQtZGlzYWJsZWQiLCJwdWJsaWNrZXktY2hhbmdlLWRpc2FibGVkIiwibWZhLWRpc2FibGVkIiwiYXBpLWtleS1hdXRoLWNoYW5nZS1kaXNhYmxlZCIsImluZm8tY2hhbmdlLWRpc2FibGVkIiwic2hhcmVzLWRpc2FibGVkIiwic2hhcmVzLXdpdGhvdXQtcGFzc3dvcmQtZGlzYWJsZWQiXSwic3ViIjoiMTcwNjYyNTQ3MDM1MyIsInVzZXJuYW1lIjoiemlkd2NqcXBzd21xMHQzczd1c3M3dG5wIn0.2PsLujc0eN3I-n69C22NWR3NGZrLuQU8WaF1coBOalA' \
-H 'Content-Type: multipart/form-data' \
-F 'filenames=@scan.csv;type=text/csv'

In the "Authorization" section, replace the token with the one retrieved in the previous step (and add Bearer in front).

The Content-Type must be multipart/form-data and the file must be sent in the filenames field as in the example (adapt with your file name) and the type must be text/csv.

The command returns a 201 code indicating that the file has been sent.

{
"message": "Upload completed"
}

The file is now uploaded and will be processed within seconds.