How to upload an image (binary data) to gitlab project

Hey Guys,

I want to upload an image to a gitlab project using the Gitlab Project Upload API. Since this is not part of the gitlab integration I have to do it with the request node. My whole workflow creates a snapshot of an html email with puppeteer and and then (hopefully) adds it as a comment to a gitlab issue.

Describe the issue/error/question

The API works a described when I upload the file with curl, but I am getting a 400 Bad Request response from Gitlab in my workflow.

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.209.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Any help and directions would be much appreciated.

Thanks for n8n!!

Hey @toxsick,

Welcome to the community :cake:

This isn’t going to help you right now but it looks like @svzi put in a PR to add support for this over the weekend (feat(GitLab): added file operations (create, delete, edit, get, list) by svzi · Pull Request #5167 · n8n-io/n8n · GitHub).

I am not familiar with the GitLab API but I will set aside a bit of time to test posting from the HTTP Request later today unless @svzi already has a magic workflow for that :slight_smile:

Great timing @toxsick :smiley:

I’ve tested my implementation with binary files and I was able to get it going. Needed to do some tweaks, but the PR is already updated. The PR includes a workflow for testing purposes. That workflow now also contains nodes for binary file handling.

Hope it will get reviewed soon @Jon :pray:

Hey Guys,

AWESOME :star_struck: :heart_eyes: This is even better and no problem, I can wait a bit for this to get merged…

Thanks for putting in the work!

Or Not?! I think I was a little bit to fast with my cheering :thinking:

@svzi your PR adds support for the Repository files API right? (files of the git repository)

I want to use the Project → Upload a file API (generic upload endpoint for project related files that is used e.g. when you attach an image to an Issue)

Good thing is since @svzi seems to have figured out the hard (binary file upload) part. Adding support for this API should be also easy I think.

@toxsick Sad to say you’re right, at least sad about the part that I’ve only implemented the Repository files API.

I had a look at your API but sadly the file upload works not the same as in the files API. If it had been the same way I would have given it a try, but now I need to refuse. Sorry, maybe someone else can pick it up.

Hey Guys,

took me a while, but anyone having the same Problem, I was able to solve this with the normal request node.

The root cause was that my binary input (created by the puppeteer node) did not have a “File Name” set and that was what gitlab was rejecting (without really telling me except 400 - Bad Request…)

So I solved this with an additional code node and now it works: