How to upload files using rest API (Command Line & Terminal)?

Been reviewing the upload steps in the API documentation but so far haven’t been able get it to work.

In this case I’m trying to automate Version uploads…

Request for ‘upload URL’ is

curl -X GET https//{VersionId}/_upload?\filename={FileName} \
-H 'Authorization: Bearer {BearerToken} \
-H 'Accept: application/json'

Result is

	"UrlRequest": {
		"data": {
			"timestamp": "2021-11-23T20:20:05Z",
			"upload_type": "Attachment",
			"upload_id": null,
			"storage_service": "s3",
			"original_filename": "[FileName]",
			"multipart_upload": false
		"links": {
			"upload": "https://[s3domain][longstring1]/[longstring2]/[FileName]
			"complete_upload": "/api/v1/entity/versions/{VersionId}/_upload"

then the Upload request is

curl -X PUT https//${VersionId}/_upload\
&expiration=[Expiration]` \
-H 'Content-Type: */* \
-H 'Accept: application/json' \
-H 'Authorization: Bearer ${BearerToken}'
-d '@[FilePath]'

And I get the following error

	"errors": [
			"id": 1,
			"status": 400,
			"code": 103,
			"title": "Signature did not match",
			"source": {},
			"detail": null,
			"meta": null

Hi @Cmq

I believe that you need to upload your file to the upload location returned by your initial call.

Media is stored on Amazon’s S3, so this is where you need to upload the file, using all of the X-Amz-* headers in your call.


Thank you for that. Is there specific documentation for this that you’re aware of?

I’m familiar with Amazon’s aws-cli library, but based your note, that’s not in play here.

Running with your suggestion I did the follwing…

		curl -X POST \
		-H 'X-Amz-Algorithm=XXX' \
		-H 'X-Amz-Credential=XXX' \
		-H 'X-Amz-Date=XXX' \
		-H 'X-Amz-Expires=900' \
		-H 'X-Amz-SignedHeaders=host' \
		-H 'X-Amz-Security-Token=XXX' \
		-H 'X-Amz-Signature=XXX' \
		-d '@/Volumes/Path/To/File' \

The URL above was derived from the returned URL taking everything to the left of the query string. The headers were all derived by parsing the query string itself

Results so far are an error saying the data set included in the headers is too large (see below)

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
 <Message>Your request header section exceeds the maximum allowed size.</Message

Hello @Cmq

S3 uploads are done via the PUT http command.
You can use the upload link url like this:

curl -X PUT \
     -H 'Content-Type=%content_type%' \
     -H 'x-amz-meta-original-filename=%filename%' \
     -d '@/Volumes/Path/To/Upload/Image' \

%content_type% is the content type of the file you want to upload ( ex: image/jpg )
%filename% is the filename of the file you want to upload ( ex: image.jpg )
%receivedUploadLink% is the “UrlRequest” > “links” > “upload” field of the Upload URL request result