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
992643b4
Commit
992643b4
authored
Nov 17, 2020
by
Alexander Strachan
Committed by
Mike Jang
Nov 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "docs add more curl usage examples"
parent
cd1907a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
doc/api/README.md
doc/api/README.md
+27
-2
No files found.
doc/api/README.md
View file @
992643b4
...
@@ -72,9 +72,11 @@ Only API version v4 is available. Version v3 was removed in
...
@@ -72,9 +72,11 @@ Only API version v4 is available. Version v3 was removed in
API requests should be prefixed with both
`api`
and the API version. The API
API requests should be prefixed with both
`api`
and the API version. The API
version is defined in
[
`lib/api.rb`
](
https://gitlab.com/gitlab-org/gitlab/tree/master/lib/api/api.rb
)
.
version is defined in
[
`lib/api.rb`
](
https://gitlab.com/gitlab-org/gitlab/tree/master/lib/api/api.rb
)
.
For example, the root of the v4 API is at
`/api/v4`
.
For example, the root of the v4 API is at
`/api/v4`
.
The following sections illustrate different uses:
Example of a valid API request using cURL:
### Valid API request
If you have a GitLab instance at
`gitlab.example.com`
:
```
shell
```
shell
curl
"https://gitlab.example.com/api/v4/projects"
curl
"https://gitlab.example.com/api/v4/projects"
...
@@ -83,6 +85,29 @@ curl "https://gitlab.example.com/api/v4/projects"
...
@@ -83,6 +85,29 @@ curl "https://gitlab.example.com/api/v4/projects"
The API uses JSON to serialize data. You don't need to specify
`.json`
at the
The API uses JSON to serialize data. You don't need to specify
`.json`
at the
end of an API URL.
end of an API URL.
### API request to expose HTTP response headers
If you want to expose HTTP response headers, use the
`--include`
option:
```
shell
curl
--include
"https://gitlab.example.com/api/v4/projects"
HTTP/2 200
...
```
This can help you investigate an unexpected response.
### API Request that includes the exit code
If you want to expose the HTTP exit code, include the
`--fail`
option:
```
shell script
curl --fail "https://gitlab.example.com/api/v4/does-not-exist"
curl: (22) The requested URL returned error: 404
```
The HTTP exit code can help you diagnose the success or failure of your REST call.
## Authentication
## Authentication
Most API requests require authentication, or will return public data only when
Most API requests require authentication, or will return public data only when
...
...
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