# Using SDS with the command line
# Pre-production environment
Using the command line to manually upload documents to SDS is not something you would normally do in a production scenario. It can however be very convenient during testing and when understanding how the service works. The following examples use cURL to execute HTTP requests from the command line:
# Uploading a text document using cURL
# Windows curl -u demo:Bond007 -k -d "Test document with ÅÆØ" -H "Content-Type: text/plain;charset=iso8859-1" https://preprod.signicat.com/doc/demo/sds # OS X/Linux curl -u demo:Bond007 -k -d "Test document with ÅÆØ" -H "Content-Type: text/plain;charset=utf8" https://preprod.signicat.com/doc/demo/sds # Explanation of parameters: # -u service_name:password # -k accept the server SSL certificate without validation # -d request data (which implies HTTP POST instead of HTTP GET) # -H set request header
In this example, we uploaded an inline string and not really a "text document", but of course it's possible to upload a text file as well. To upload a PDF file, you need to HTTP POST the binary file in the request body. Such a cURL request for a PDF document called
mydocument.pdf is shown in the next example.
# Uploading a PDF document using cURL
# Windows/OS X/Linux curl -u demo:Bond007 -k --data-binary @mydocument.pdf -H "Content-Type: application/pdf" https://preprod.signicat.com/doc/demo/sds
Uploading a document returns a document id which can be used to download the document. The next example shows how to get the the URL for the document.
# HTTP GET URL
You can use any browser to fetch the document (username: demo, password: Bond007), or you can use cURL to issue an HTTP GET like in the example below.
# Downloading a document using cURL
curl -u demo:Bond007 -k -o mydownloadedfile.pdf https://preprod.signicat.com/doc/demo/sds/21082013yuhu3a80c1kofj1baarn1gozk32hphh9jcy6i5h9a3qk2ca7z
This will GET the file and save it as mydownloadedfile.pdf.
# Production environment
In the production environment, you will get your own web service that requires two-way SSL. This differs from the pre-production environment. For more information, refer to our documentation on the pre-production environment.
Using cURL against the production environment is something you normally would do only to verify your two-way SSL setup before going live.
For the production environment, you will receive a web service certificate in p12 format. Curl needs a certificate in pem format, so you will need to convert it first. The certificate decryption password will be provided to you after you have downloaded the necessary p12 file. Substitute the variables below:
$openssl pkcs12 -in your-webservice-certificate.p12 -out your-webservice-certificate.pem -clcerts Enter Import Password: <Enter decryption password> MAC verified OK Enter PEM pass phrase: <Enter new passphrase for the pem file here> Verifying - Enter PEM pass phrase: <Enter pem passphrase again>
You will need to replace the placeholders. The service name, certificate decryption password and web service password will be provided to you by Signicat.
When you have your web service certificate file in pem format, you can use the command below.
curl --tls1.2 --cert <./your-webservice-certificate.pem>:<pem passhrase> -u <yourservice>:<yourwebservicepassword> -k -d"Two-way SSL Uploaded document with ÆØÅ" -H "Content-Type: text/plain;charset=utf-8" https://id.signicat.com/doc/<yourservice>/sds