2

Using the GitLab API (version 8.x) it is possible to access project snippets via GET /projects/:id/snippets (see project snippets docs).

The Python request for snippet 4 of the project pr in the group gr would look like (with 2%F = /):

r = requests.get(url='https://gitlab.domain.com/api/v3/projects/gr2%Fpr/snippets/4')

But I can't figure out a way to access a snippet, which is not associated with any project, something like https://gitlab.com/snippets/14383, although the web interface can create and display those snippets. Is there a way to do that via the API?

Further information: I have a public snipped on a self hosted GitLab server, which leads to a 500 Server Error somehow and I want to delete this snippet via the API.

bastelflp
  • 9,362
  • 7
  • 32
  • 67

1 Answers1

1

I confirm (Feb. 2016) this API does not seem to exist at the moment (in the GitLab API doc).

There was an old 2013 suggestion for public snippet API in 2013, but that issue has not been reported in the current GitLab.org/GitLab Community Edition project.

So... PR are welcome.


Update June 2016:

The OP bastelflp adds in the comments:

In the meantime GitLab was updated some times.
With the current version 8.8.5, the snippets did not cause a 500 error anymore and could be deleted via the web interface.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Ok, thanks for the confirmation of my problem, so it is a thing. Do you have any idea how to delete a snipped which causes a `500` from the web interface? – bastelflp Feb 02 '16 at 12:47
  • @bastelflp I do not know that. 500 means exception at the server level. What do the GitLab logs show? – VonC Feb 02 '16 at 12:49
  • The log is here: http://pastebin.com/LCykQ8y2 and it shows `ActionView::Template::Error (undefined method \`path_with_namespace' for nil:NilClass):` and I used `path_with_namespace` somewhere in the snipped (it was a markdown `snippet.md`). So it seems to be a parsing error for my content. – bastelflp Feb 02 '16 at 13:33
  • In the meantime GitLab was updated some times and with the current version `8.8.5` the snippets did not cause a `500` error anymore and could be deleted via the web interface. – bastelflp Jun 30 '16 at 13:08
  • 1
    @bastelflp Sounds great! I have included your comment in the answer for more visibility. – VonC Jun 30 '16 at 14:35