Here is a code sample to help you with your Multipart Authentication method implementation. This example is run on the ****Upload a file endpoint.

Bash

#! /bin/bash

# Put your public key here, keep it on a single line
PUB_KEY="-----BEGIN RSA PUBLIC KEY-----MEgCQQCEKhb6dK63DNuPVZAeOGPL1vvxOtkaKJn7j3x5PNKicgeGjI6fwHHo/HlYBVnBMnBhAuvo/EQqqX0gGs7yVvv9AgMBAAE=-----END RSA PUBLIC KEY-----"

# Put your private key here, with the line breaks
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJBAIQqFvp0rrcM249VkB44Y8vW+/E62Room
fuPfHk80qJyB4aPHp/Acej8eVgFWcEycGEC6+j8RCqpfS
AazvJW+/0CAwEAAQJAQiTKcTg6RHRT4e1Bfk5ca6TBXF5
GTxgo0ERkWEy/YfqT6y765XqNo8rYibTAJnIm74axEDaW
91gOajDDJYSzAQIhANF8hqgSAi5ROtt4I0lk4oOI7NFKd
yR1993Iiz+yeF49AiEAoYJ7fojkihX+EpKEOV/8bk1gcW
+vKSqJCadR44LmsMEOIBVPkLdKVbR2iQFIoHZX7/8nj8f
exm4MHjIOs7PAKSSVAiBjNuesBGX4Gah5Oj41jKxiCfBb
3tLIRBPotTtNuoUCQQIgUZJ8Yutui/cAyd+IFSRNuVCUO
kOpr/611pQ3212Xuec=
-----END RSA PRIVATE KEY-----"

# Get the current UNIX timestamp and generate a random string
TIMESTAMP=$(date +%s)
NONCE=$(openssl rand -hex 8)

# File
TMP_FILEPATH=$(mktemp)
TMP_DIR=$(dirname $TMP_FILEPATH | sed 's,^\\(.*/\\)\\?\\([^/]*\\),\\2,')
echo "Hello world!" > $TMP_FILEPATH
FILENAME="myFile.txt"
FILEPATH="$TMP_DIR/$FILENAME"
mv $TMP_FILEPATH $FILEPATH
FILESIZE=$(wc -c < "$FILEPATH")
FILETYPE=$(file -b --mime-type "$FILEPATH")
FILE=$(printf '{"name":"%s","size":"%s","type":"%s"}' $FILENAME $FILESIZE $FILETYPE)

# BODY
PROPERTY_ID="12345"
CATEGORY="PROPERTY_PLANS"
BODY=$(printf '{"category":"%s","propertyId":"%s"}' $CATEGORY $PROPERTY_ID)

# JSON object to be signed
# Please respect the order or your signature won't be validated
TO_SIGN=$(printf '{"security":{"nonce":"%s","timestamp":"%s"},"body":%s,"file":%s}' $NONCE $TIMESTAMP $BODY $FILE)

# Generate the signature
SIGN=$(echo $TO_SIGN | tr -d '\\n' | openssl dgst -sha256 -sign <(echo "${PRIVATE_KEY}") | base64)

# Make the request
curl \\
-X POST \\
'<https://api.resolve.ch/api/files>' \\
-H "X-RESOLVE-Authorization: RESOLVE ${PUB_KEY}:${SIGN}" \\
-H "X-RESOLVE-Nonce: ${NONCE}" \\
-H "X-RESOLVE-Timestamp: ${TIMESTAMP}" \\
-F "propertyId=${PROPERTY_ID}" \\
-F "category=${CATEGORY}" \\
-F "file=@${FILEPATH}"