Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3da9fef0
Commit
3da9fef0
authored
Dec 04, 2018
by
colinleroy
Committed by
Evan Read
Dec 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lack of documentation on how to fetch a snippet's content using API
parent
2b2f9369
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
changelogs/unreleased/document-raw-snippet-api.yml
changelogs/unreleased/document-raw-snippet-api.yml
+5
-0
doc/api/snippets.md
doc/api/snippets.md
+32
-8
No files found.
changelogs/unreleased/document-raw-snippet-api.yml
0 → 100644
View file @
3da9fef0
---
title
:
Fix lack of documentation on how to fetch a snippet's content using API
merge_request
:
23448
author
:
Colin Leroy
type
:
other
doc/api/snippets.md
View file @
3da9fef0
...
...
@@ -37,13 +37,13 @@ Parameters:
| --------- | ---- | -------- | ----------- |
|
`id`
| Integer | yes | The ID of a snippet |
```
bash
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/snippets/1
```
Example response:
```
json
```
json
{
"id"
:
1
,
"title"
:
"test"
,
...
...
@@ -65,6 +65,30 @@ Example response:
}
```
## Single snippet contents
Get a single snippet's raw contents.
```
GET /snippets/:id/raw
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| Integer | yes | The ID of a snippet |
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/snippets/1/raw
```
Example response:
```
Hello World snippet
```
## Create new snippet
Creates a new snippet. The user must have permission to create new snippets.
...
...
@@ -84,7 +108,7 @@ Parameters:
|
`visibility`
| String | no | The snippet's visibility |
```
bash
```
bash
curl
--request
POST
\
--data
'{"title": "This is a snippet", "content": "Hello world", "description": "Hello World snippet", "file_name": "test.txt", "visibility": "internal" }'
\
--header
'Content-Type: application/json'
\
...
...
@@ -94,7 +118,7 @@ curl --request POST \
Example response:
```
json
```
json
{
"id"
:
1
,
"title"
:
"This is a snippet"
,
...
...
@@ -136,7 +160,7 @@ Parameters:
|
`visibility`
| String | no | The snippet's visibility |
```
bash
```
bash
curl
--request
PUT
\
--data
'{"title": "foo", "content": "bar"}'
\
--header
'Content-Type: application/json'
\
...
...
@@ -146,7 +170,7 @@ curl --request PUT \
Example response:
```
json
```
json
{
"id"
:
1
,
"title"
:
"test"
,
...
...
@@ -201,13 +225,13 @@ GET /snippets/public
|
`per_page`
| Integer | no | number of snippets to return per page |
|
`page`
| Integer | no | the page to retrieve |
```
bash
```
bash
curl
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/snippets/public?per_page
=
2&page
=
1
```
Example response:
```
json
```
json
[
{
"author"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment