File upload using API

Hello everyone.

I want to upload multiple documents using a Powsershell script via API.
As a first step, I try to upload a single document, but I always get “bad request” (400) as an error message.

I already gone through the references, unfortunately without success.

$api_token ="01234012301234"
$server = "https/"

$headers.Add("accept", "application/json")
$headers.Add("content-type", "application/json")
$headers.Add("authorization", "Bearer $api_token")

$response = Invoke-WebRequest -Uri $server'/app-upload-link/' -Method GET -Headers $headers|ConvertFrom-Json
$uploadUrl = $response.upload_link
$parentDir = $response.parent_path
$relPath = $response.file_relative_path
$replace = "0"

$output = Invoke-WebRequest -Uri $uploadUrl'?ret-json=1' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001
Content-Disposition: form-data; name="file"

Content-Disposition: form-data; name="parent_dir"

Content-Disposition: form-data; name="replace"

Content-Disposition: form-data; name="relative_path"



Maybe someone can help me solving the issue.

Thank you.

I am not familiar with powershell, but I think you use the API in the wrong way:

This is what you get from /app-upload-link/

  "upload_link": "",
  "parent_path": "/asset/a275d870-fd55-48e4-8c4a-5fd6f2549765",
  "img_relative_path": "images/2021-08",
  "file_relative_path": "files/2021-08"

You can not just use $response.upload_link. The api request to upload a file only requires the part after the upload-api. Please read the api documentation again.

Thank you for the answer, but I think this wont help me.
According to Seatable Reference Upload-File-Image the Invoke-WebRequest expect the full link with the upload_link.

$headers.Add("accept", "application/json")
$headers.Add("content-type", "multipart/form-data")
$response = Invoke-WebRequest -Uri '' -Method POST -Headers $headers

The exception handling contains follwing content:

IsMutuallyAuthenticated : False
Cookies                 : {}
Headers                 : {Connection, Content-Length, Content-Type, Date...}
SupportsHeaders         : True
ContentLength           : 26
ContentEncoding         : 
ContentType             : application/json; charset=utf-8
CharacterSet            : utf-8
Server                  : nginx/1.24.0
LastModified            : 23.02.2024 10:10:16
StatusCode              : BadRequest
StatusDescription       : Bad Request
ProtocolVersion         : 1.1
ResponseUri             :
Method                  : POST
IsFromCache             : False

Unfortunately I haven’t come to a solution yet.

I can guarantee you that the API endpoint is working as described on

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.