API: upload a video, can not finde a correct tags format

Hello,

I am trying to write a script, using python, that uploads videos to my server. I use the API function « /videos/upload ». Everything works, I can specify all the data. Only the tags make problems I always get the following errors:

warn: Incorrect request parameters {
  "path": "/api/v1/videos/upload",
  "err": {
    "tags": {
      "value": "('hello', 'super')",
      "msg": { "should have correct tags",
      }, "param": { "tags",
      "location": "body"
    }
  }
}

I have tried many ways to specify the tags, the only one where this error does not appear is:

("hello", "jojona")

Or

["hello", "jojona"]

but then I get another error:

Server Error
error: Error in controller. {
"err": "MulterError: Unexpected field\n    at wrappedFileFilter (/app/node_modules/multer/index.js:40:19)\n    at Busboy.<anonymous> (/app/node_modules/multer/lib/make-middleware.js:114:7)\n    at Busboy.emit (events.js:198:13)\n    at Busboy.emit (/app/node_modules/busboy/lib/main.js:38:33)\n    at PartStream.<anonymous> (/app/node_modules/busboy/lib/types/multipart.js:213:13)\n    at PartStream.emit (events.js:198:13)\n    at HeaderParser.<anonymous> (/app/node_modules/dicer/lib/Dicer.js:51:16)\n    at HeaderParser.emit (events.js:198:13)\n    at HeaderParser._finish (/app/node_modules/dicer/lib/HeaderParser.js:68:8)\n    at SBMH.<anonymous> (/app/node_modules/dicer/lib/HeaderParser.js:40:12)\n    at SBMH.emit (events.js:198:13)\n    at SBMH._sbmh_feed (/app/node_modules/streamsearch/lib/sbmh.js:159:14)\n    at SBMH.push (/app/node_modules/streamsearch/lib/sbmh.js:56:14)\n    at HeaderParser.push (/app/node_modules/dicer/lib/HeaderParser.js:46:19)\n    at Dicer._oninfo (/app/node_modules/dicer/lib/Dicer.js:197:25)\n    at SBMH.<anonymous> (/app/node_modules/dicer/lib/Dicer.js:127:10)\n    at SBMH.emit (events.js:198:13)\n    at SBMH._sbmh_feed (/app/node_modules/streamsearch/lib/sbmh.js:159:14)\n    at SBMH.push (/app/node_modules/streamsearch/lib/sbmh.js:56:14)\n    at Dicer._write (/app/node_modules/dicer/lib/Dicer.js:109:17)\n    at doWrite (_stream_writable.js:415:12)\n    at writeOrBuffer (_stream_writable.js:399:5)\n    at Dicer.Writable.write (_stream_writable.js:299:11)\n    at Multipart.write (/app/node_modules/busboy/lib/types/multipart.js:290:24)\n    at Busboy._write (/app/node_modules/busboy/lib/main.js:81:16)\n    at doWrite (_stream_writable.js:415:12)\n    at writeOrBuffer (_stream_writable.js:399:5)\n    at Busboy.Writable.write (_stream_writable.js:299:11)"
}

My multipart data looks like this:

multipart/form-data

<MultipartEncoder: [(‹ name ›, ‹ Home ›), (‹ licence ›, ‹ 1 ›), (‹ description ›, ‹ test cool ›), (‹ tags ›, (‹ hallo ›, ‹ jojona ›)), (‹ nsfw ›, ‹ false ›), (‹ channelId ›, ‹ 4 ›), (‹ originallyPublishedAt ›, ‹ 2021-03-11T17:00:12+00:00 ›), (‹ category ›, ‹ 11 ›), (‹ language ›, ‹ de ›), (‹ privacy ›, ‹ 1 ›), (‹ commentsEnabled ›, ‹ true ›), (‹ videofile ›, (‹ aZiXjsNSPTQ_1080.mp4 ›, <_io.BufferedReader name=‹ /home/user/download/peertube/aZiXjsNSPTQ_1080.mp4 ›>, ‹ video/mp4 ›)), (‹ thumbnailfile ›, (‹ Lo3rSOrksjo.jpg ›, <_io.BufferedReader name=‹ /home/user/download/peertube/Lo3rSOrksjo.jpg ›>, ‹ image/jpeg ›)), (‹ previewfile ›, (‹ Lo3rSOrksjo.jpg ›, <_io.BufferedReader name=‹ /home/user/download/peertube/Lo3rSOrksjo.jpg ›>, ‹ image/jpeg ›)), (‹ waitTranscoding ›, ‹ false ›)]>

I have already found the following posts about this in the forum but I could not find a solution:

What am I doing wrong, is there a solution?

Hi,

I’m sorry but I don’t know python. You can help yourself using this existing python script that uploads videos on peertube: https://git.lecygnenoir.info/LecygneNoir/prismedia/src/branch/master/prismedia/pt_upload.py#L206

Thanks for your hint, I found out how to create a String Array MultipartEncoder. In my case for the endpoint /api/v1/videos/upload, you have to double tap the field:

fields=[
    ...
    ('tags', 'Tag 1'),
    ('tags', 'foo'),
    ('tags', 'bar'), 
    ('tags', 'Tag 4'),
    ...
]

I found the solution here: