mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-04-29 19:58:52 +00:00
658 lines
45 KiB
Text
658 lines
45 KiB
Text
<!DOCTYPE html>
|
|
|
|
<html class="" lang="en">
|
|
<head prefix="og: http://ogp.me/ns#">
|
|
<meta charset="utf-8"/>
|
|
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
|
|
<meta content="object" property="og:type"/>
|
|
<meta content="GitLab" property="og:site_name"/>
|
|
<meta content="Readme · Api · Help" property="og:title"/>
|
|
<meta content="GitLab Community Edition" property="og:description"/>
|
|
<meta content="http://172.20.254.127/assets/gitlab_logo-7ae504fe4f68fdebb3c2034e36621930cd36ea87924c11ff65dbcb8ed50dca58.png" property="og:image"/>
|
|
<meta content="64" property="og:image:width"/>
|
|
<meta content="64" property="og:image:height"/>
|
|
<meta content="http://172.20.254.127/help/api/README.md" property="og:url"/>
|
|
<meta content="summary" property="twitter:card"/>
|
|
<meta content="Readme · Api · Help" property="twitter:title"/>
|
|
<meta content="GitLab Community Edition" property="twitter:description"/>
|
|
<meta content="http://172.20.254.127/assets/gitlab_logo-7ae504fe4f68fdebb3c2034e36621930cd36ea87924c11ff65dbcb8ed50dca58.png" property="twitter:image"/>
|
|
<title>Readme · Api · Help · GitLab</title>
|
|
<meta content="GitLab Community Edition" name="description"/>
|
|
<link data-original-href="/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png" href="/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png" id="favicon" rel="shortcut icon" type="image/png"/>
|
|
<link href="/assets/application-266f2bfa52ff531258d13c702895a14fd5994ca591fa2df7338da00ab18c99ac.css" media="all" rel="stylesheet"/>
|
|
<link href="/assets/print-c8ff536271f8974b8a9a5f75c0ca25d2b8c1dceb4cff3c01d1603862a0bdcbfc.css" media="print" rel="stylesheet"/>
|
|
<script>
|
|
//<![CDATA[
|
|
window.gon={};gon.api_version="v4";gon.default_avatar_url="http://172.20.254.127/assets/no_avatar-849f9c04a3a0d0cea2424ae97b27447dc64a7dbfae83c036c45b403392f0e8ba.png";gon.max_file_size=10;gon.asset_host=null;gon.webpack_public_path="/assets/webpack/";gon.relative_url_root="";gon.shortcuts_path="/help/shortcuts";gon.user_color_scheme="white";gon.gitlab_url="http://172.20.254.127";gon.revision="63daf37";gon.gitlab_logo="/assets/gitlab_logo-7ae504fe4f68fdebb3c2034e36621930cd36ea87924c11ff65dbcb8ed50dca58.png";gon.sprite_icons="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg";gon.sprite_file_icons="/assets/file_icons-7262fc6897e02f1ceaf8de43dc33afa5e4f9a2067f4f68ef77dcc87946575e9e.svg";gon.emoji_sprites_css_path="/assets/emoji_sprites-289eccffb1183c188b630297431be837765d9ff4aed6130cf738586fb307c170.css";gon.test_env=false;gon.suggested_label_colors=["#0033CC","#428BCA","#44AD8E","#A8D695","#5CB85C","#69D100","#004E00","#34495E","#7F8C8D","#A295D6","#5843AD","#8E44AD","#FFECDB","#AD4363","#D10069","#CC0033","#FF0000","#D9534F","#D1D100","#F0AD4E","#AD8D43"];
|
|
//]]>
|
|
</script>
|
|
<script defer="defer" src="/assets/webpack/runtime.9fcb75d4.bundle.js"></script>
|
|
<script defer="defer" src="/assets/webpack/main.a66b6c66.chunk.js"></script>
|
|
<script defer="defer" src="/assets/webpack/pages.help.show.c42c0700.chunk.js"></script>
|
|
<meta content="authenticity_token" name="csrf-param">
|
|
<meta content="0L9G+IOwsal/+UQpxMOJ8XzqRVRBYfCij/65gmHSJMvYhuZIcCvPHS8I+CdfnKKRMhmyyy3OcxkN5CIVz8w6MA==" name="csrf-token">
|
|
<meta content="origin-when-cross-origin" name="referrer"/>
|
|
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport"/>
|
|
<meta content="#474D57" name="theme-color"/>
|
|
<link href="/assets/touch-icon-iphone-5a9cee0e8a51212e70b90c87c12f382c428870c0ff67d1eb034d884b78d2dae7.png" rel="apple-touch-icon" type="image/x-icon"/>
|
|
<link href="/assets/touch-icon-ipad-a6eec6aeb9da138e507593b464fdac213047e49d3093fc30e90d9a995df83ba3.png" rel="apple-touch-icon" sizes="76x76" type="image/x-icon"/>
|
|
<link href="/assets/touch-icon-iphone-retina-72e2aadf86513a56e050e7f0f2355deaa19cc17ed97bbe5147847f2748e5a3e3.png" rel="apple-touch-icon" sizes="120x120" type="image/x-icon"/>
|
|
<link href="/assets/touch-icon-ipad-retina-8ebe416f5313483d9c1bc772b5bbe03ecad52a54eba443e5215a22caed2a16a2.png" rel="apple-touch-icon" sizes="152x152" type="image/x-icon"/>
|
|
<link color="rgb(226, 67, 41)" href="/assets/logo-d36b5212042cebc89b96df4bf6ac24e43db316143e89926c0db839ff694d2de4.svg" rel="mask-icon"/>
|
|
<meta content="/assets/msapplication-tile-1196ec67452f618d39cdd85e2e3a542f76574c071051ae7effbfde01710eb17d.png" name="msapplication-TileImage"/>
|
|
<meta content="#30353E" name="msapplication-TileColor"/>
|
|
</meta></meta></head>
|
|
<body class="ui-indigo " data-group="" data-page="help:show" data-project="">
|
|
<header class="navbar navbar-gitlab qa-navbar navbar-expand-sm">
|
|
<a class="sr-only gl-accessibility" href="#content-body" tabindex="1">Skip to content</a>
|
|
<div class="container-fluid">
|
|
<div class="header-content">
|
|
<div class="title-container">
|
|
<h1 class="title">
|
|
<a href="/" id="logo" title="Dashboard"><svg class="tanuki-logo" height="24" viewbox="0 0 36 36" width="24">
|
|
<path class="tanuki-shape tanuki-left-ear" d="M2 14l9.38 9v-9l-4-12.28c-.205-.632-1.176-.632-1.38 0z" fill="#e24329"></path>
|
|
<path class="tanuki-shape tanuki-right-ear" d="M34 14l-9.38 9v-9l4-12.28c.205-.632 1.176-.632 1.38 0z" fill="#e24329"></path>
|
|
<path class="tanuki-shape tanuki-nose" d="M18,34.38 3,14 33,14 Z" fill="#e24329"></path>
|
|
<path class="tanuki-shape tanuki-left-eye" d="M18,34.38 11.38,14 2,14 6,25Z" fill="#fc6d26"></path>
|
|
<path class="tanuki-shape tanuki-right-eye" d="M18,34.38 24.62,14 34,14 30,25Z" fill="#fc6d26"></path>
|
|
<path class="tanuki-shape tanuki-left-cheek" d="M2 14L.1 20.16c-.18.565 0 1.2.5 1.56l17.42 12.66z" fill="#fca326"></path>
|
|
<path class="tanuki-shape tanuki-right-cheek" d="M34 14l1.9 6.16c.18.565 0 1.2-.5 1.56L18 34.38z" fill="#fca326"></path>
|
|
</svg>
|
|
<span class="logo-text d-none d-sm-block">
|
|
<svg viewbox="0 0 617 169" xmlns="http://www.w3.org/2000/svg"><path d="M315.26 2.97h-21.8l.1 162.5h88.3v-20.1h-66.5l-.1-142.4M465.89 136.95c-5.5 5.7-14.6 11.4-27 11.4-16.6 0-23.3-8.2-23.3-18.9 0-16.1 11.2-23.8 35-23.8 4.5 0 11.7.5 15.4 1.2v30.1h-.1m-22.6-98.5c-17.6 0-33.8 6.2-46.4 16.7l7.7 13.4c8.9-5.2 19.8-10.4 35.5-10.4 17.9 0 25.8 9.2 25.8 24.6v7.9c-3.5-.7-10.7-1.2-15.1-1.2-38.2 0-57.6 13.4-57.6 41.4 0 25.1 15.4 37.7 38.7 37.7 15.7 0 30.8-7.2 36-18.9l4 15.9h15.4v-83.2c-.1-26.3-11.5-43.9-44-43.9M557.63 149.1c-8.2 0-15.4-1-20.8-3.5V70.5c7.4-6.2 16.6-10.7 28.3-10.7 21.1 0 29.2 14.9 29.2 39 0 34.2-13.1 50.3-36.7 50.3m9.2-110.6c-19.5 0-30 13.3-30 13.3v-21l-.1-27.8h-21.3l.1 158.5c10.7 4.5 25.3 6.9 41.2 6.9 40.7 0 60.3-26 60.3-70.9-.1-35.5-18.2-59-50.2-59M77.9 20.6c19.3 0 31.8 6.4 39.9 12.9l9.4-16.3C114.5 6 97.3 0 78.9 0 32.5 0 0 28.3 0 85.4c0 59.8 35.1 83.1 75.2 83.1 20.1 0 37.2-4.7 48.4-9.4l-.5-63.9V75.1H63.6v20.1h38l.5 48.5c-5 2.5-13.6 4.5-25.3 4.5-32.2 0-53.8-20.3-53.8-63-.1-43.5 22.2-64.6 54.9-64.6M231.43 2.95h-21.3l.1 27.3v94.3c0 26.3 11.4 43.9 43.9 43.9 4.5 0 8.9-.4 13.1-1.2v-19.1c-3.1.5-6.4.7-9.9.7-17.9 0-25.8-9.2-25.8-24.6v-65h35.7v-17.8h-35.7l-.1-38.5M155.96 165.47h21.3v-124h-21.3v124M155.96 24.37h21.3V3.07h-21.3v21.3"></path></svg>
|
|
</span>
|
|
</a></h1>
|
|
<ul class="list-unstyled navbar-sub-nav">
|
|
<li class="home"><a class="dashboard-shortcuts-projects" href="/explore" title="Projects">Projects
|
|
</a></li><li class=""><a class="dashboard-shortcuts-groups" href="/explore/groups" title="Groups">Groups
|
|
</a></li><li class=""><a class="dashboard-shortcuts-snippets" href="/explore/snippets" title="Snippets">Snippets
|
|
</a></li><li>
|
|
<a href="/help" title="About GitLab CE">Help</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li class="nav-item d-none d-sm-none d-md-block m-auto">
|
|
<div class="search search-form">
|
|
<form accept-charset="UTF-8" action="/search" class="form-inline" method="get"><input name="utf8" type="hidden" value="✓"/><div class="search-input-container">
|
|
<div class="search-input-wrap">
|
|
<div class="dropdown" data-url="/search/autocomplete">
|
|
<input aria-label="Search" autocomplete="off" class="search-input dropdown-menu-toggle no-outline js-search-dashboard-options" data-issues-path="/dashboard/issues" data-mr-path="/dashboard/merge_requests" id="search" name="search" placeholder="Search" spellcheck="false" tabindex="1" type="search"/>
|
|
<button class="hidden js-dropdown-search-toggle" data-toggle="dropdown" type="button"></button>
|
|
<div class="dropdown-menu dropdown-select">
|
|
<div class="dropdown-content"><ul>
|
|
<li class="dropdown-menu-empty-item">
|
|
<a>
|
|
Loading...
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div><div class="dropdown-loading"><i aria-hidden="true" class="fa fa-spinner fa-spin" data-hidden="true"></i></div>
|
|
</div>
|
|
<svg class="s16 search-icon"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#search"></use></svg>
|
|
<svg class="s16 clear-icon js-clear-input"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#close"></use></svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<input class="js-search-group-options" id="group_id" name="group_id" type="hidden"/>
|
|
<input class="js-search-project-options" id="search_project_id" name="project_id" type="hidden" value=""/>
|
|
<input id="repository_ref" name="repository_ref" type="hidden"/>
|
|
<div class="search-autocomplete-opts hide" data-autocomplete-path="/search/autocomplete"></div>
|
|
</form></div>
|
|
</li>
|
|
<li class="nav-item d-inline-block d-sm-none d-md-none">
|
|
<a aria-label="Search" data-container="body" data-placement="bottom" data-toggle="tooltip" href="/search" title="Search"><svg class="s16"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#search"></use></svg>
|
|
</a></li>
|
|
<li class="nav-item">
|
|
<div>
|
|
<a class="btn btn-sign-in" href="/users/sign_in?redirect_to_referer=yes">Sign in / Register</a>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<button class="navbar-toggler d-block d-sm-none" type="button">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<svg class="s12 more-icon js-navbar-toggle-right"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#more"></use></svg>
|
|
<svg class="s12 close-icon js-navbar-toggle-left"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#close"></use></svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div class="layout-page">
|
|
<div class="content-wrapper">
|
|
<div class="mobile-overlay"></div>
|
|
<div class="alert-wrapper">
|
|
<nav class="breadcrumbs container-fluid container-limited" role="navigation">
|
|
<div class="breadcrumbs-container">
|
|
<div class="breadcrumbs-links js-title-container">
|
|
<ul class="list-unstyled breadcrumbs-list js-breadcrumbs-list">
|
|
<li><a href="/help">Help</a><svg class="s8 breadcrumbs-list-angle"><use xlink:href="/assets/icons-07542808fffaf82e9b57b144464ea42620b32f65ce441c01528d23d4b96d5f11.svg#angle-right"></use></svg></li>
|
|
<li>
|
|
<h2 class="breadcrumbs-sub-title"><a href="/help/api/README.md">Help</a></h2>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<div class="flash-container flash-container-page">
|
|
</div>
|
|
</div>
|
|
<div class="container-fluid container-limited ">
|
|
<div class="content" id="content-body">
|
|
<div class="documentation wiki prepend-top-default">
|
|
<h1 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#gitlab-api" id="user-content-gitlab-api"></a>GitLab API</h1>
|
|
<p dir="auto">Automate GitLab via a simple and powerful API. All definitions can be found
|
|
under <a href="https://gitlab.com/gitlab-org/gitlab-ce/tree/master/lib/api" rel="nofollow noreferrer noopener" target="_blank"><code>/lib/api</code></a>.</p>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#resources" id="user-content-resources"></a>Resources</h2>
|
|
<p dir="auto">Documentation for various API resources can be found separately in the
|
|
following locations:</p>
|
|
<ul dir="auto">
|
|
<li><a href="/award_emoji.md">Award Emoji</a></li>
|
|
<li><a href="/branches.md">Branches</a></li>
|
|
<li><a href="/broadcast_messages.md">Broadcast Messages</a></li>
|
|
<li><a href="/project_level_variables.md">Project-level Variables</a></li>
|
|
<li><a href="/group_level_variables.md">Group-level Variables</a></li>
|
|
<li><a href="/snippets.md">Code Snippets</a></li>
|
|
<li><a href="/commits.md">Commits</a></li>
|
|
<li><a href="/custom_attributes.md">Custom Attributes</a></li>
|
|
<li><a href="/deployments.md">Deployments</a></li>
|
|
<li><a href="/deploy_keys.md">Deploy Keys</a></li>
|
|
<li><a href="/environments.md">Environments</a></li>
|
|
<li><a href="/events.md">Events</a></li>
|
|
<li><a href="/features.md">Feature flags</a></li>
|
|
<li><a href="/templates/gitignores.md">Gitignores templates</a></li>
|
|
<li><a href="/templates/gitlab_ci_ymls.md">GitLab CI Config templates</a></li>
|
|
<li><a href="/groups.md">Groups</a></li>
|
|
<li><a href="/access_requests.md">Group Access Requests</a></li>
|
|
<li><a href="/group_badges.md">Group Badges</a></li>
|
|
<li><a href="/members.md">Group Members</a></li>
|
|
<li><a href="/issues.md">Issues</a></li>
|
|
<li><a href="/boards.md">Issue Boards</a></li>
|
|
<li><a href="/group_boards.md">Group Issue Boards</a></li>
|
|
<li><a href="/jobs.md">Jobs</a></li>
|
|
<li><a href="/keys.md">Keys</a></li>
|
|
<li><a href="/labels.md">Labels</a></li>
|
|
<li><a href="/markdown.md">Markdown</a></li>
|
|
<li><a href="/merge_requests.md">Merge Requests</a></li>
|
|
<li><a href="/milestones.md">Project milestones</a></li>
|
|
<li><a href="/group_milestones.md">Group milestones</a></li>
|
|
<li><a href="/namespaces.md">Namespaces</a></li>
|
|
<li>
|
|
<a href="/notes.md">Notes</a> (comments)</li>
|
|
<li>
|
|
<a href="/discussions.md">Discussions</a> (threaded comments)</li>
|
|
<li><a href="/notification_settings.md">Notification settings</a></li>
|
|
<li><a href="/templates/licenses.md">Open source license templates</a></li>
|
|
<li><a href="/pages_domains.md">Pages Domains</a></li>
|
|
<li><a href="/pipelines.md">Pipelines</a></li>
|
|
<li><a href="/pipeline_triggers.md">Pipeline Triggers</a></li>
|
|
<li><a href="/pipeline_schedules.md">Pipeline Schedules</a></li>
|
|
<li>
|
|
<a href="/projects.md">Projects</a> including setting Webhooks</li>
|
|
<li><a href="/access_requests.md">Project Access Requests</a></li>
|
|
<li><a href="/project_badges.md">Project Badges</a></li>
|
|
<li><a href="/project_import_export.md">Project import/export</a></li>
|
|
<li><a href="/members.md">Project Members</a></li>
|
|
<li><a href="/project_snippets.md">Project Snippets</a></li>
|
|
<li><a href="/protected_branches.md">Protected Branches</a></li>
|
|
<li><a href="/repositories.md">Repositories</a></li>
|
|
<li><a href="/repository_files.md">Repository Files</a></li>
|
|
<li><a href="/runners.md">Runners</a></li>
|
|
<li><a href="/search.md">Search</a></li>
|
|
<li><a href="/services.md">Services</a></li>
|
|
<li><a href="/settings.md">Settings</a></li>
|
|
<li><a href="/sidekiq_metrics.md">Sidekiq metrics</a></li>
|
|
<li><a href="/system_hooks.md">System Hooks</a></li>
|
|
<li><a href="/tags.md">Tags</a></li>
|
|
<li><a href="/todos.md">Todos</a></li>
|
|
<li><a href="/users.md">Users</a></li>
|
|
<li><a href="/lint.md">Validate CI configuration</a></li>
|
|
<li><a href="/v3_to_v4.md">V3 to V4</a></li>
|
|
<li><a href="/version.md">Version</a></li>
|
|
<li><a href="/wikis.md">Wikis</a></li>
|
|
</ul>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#road-to-graphql" id="user-content-road-to-graphql"></a>Road to GraphQL</h2>
|
|
<p dir="auto">Going forward, we will start on moving to
|
|
<a href="http://graphql.org/learn/best-practices/" rel="nofollow noreferrer noopener" target="_blank">GraphQL</a> and deprecate the use of
|
|
controller-specific endpoints. GraphQL has a number of benefits:</p>
|
|
<ol dir="auto">
|
|
<li>We avoid having to maintain two different APIs.</li>
|
|
<li>Callers of the API can request only what they need.</li>
|
|
<li>It is versioned by default.</li>
|
|
</ol>
|
|
<p dir="auto">It will co-exist with the current v4 REST API. If we have a v5 API, this should
|
|
be a compatibility layer on top of GraphQL.</p>
|
|
<p dir="auto">Although there were some patenting and licensing concerns with GraphQL, these
|
|
have been resolved to our satisfaction by the relicensing of the reference
|
|
implementations under MIT, and the use of the OWF license for the GraphQL
|
|
specification.</p>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#compatibility-guidelines" id="user-content-compatibility-guidelines"></a>Compatibility Guidelines</h2>
|
|
<p dir="auto">The HTTP API is versioned using a single number, the current one being 4. This
|
|
number symbolises the same as the major version number as described by
|
|
<a href="https://semver.org/" rel="nofollow noreferrer noopener" target="_blank">SemVer</a>. This mean that backward incompatible changes
|
|
will require this version number to change. However, the minor version is
|
|
not explicit. This allows for a stable API endpoint, but also means new
|
|
features can be added to the API in the same version number.</p>
|
|
<p dir="auto">New features and bug fixes are released in tandem with a new GitLab, and apart
|
|
from incidental patch and security releases, are released on the 22nd each
|
|
month. Backward incompatible changes (e.g. endpoints removal, parameters
|
|
removal etc.), as well as removal of entire API versions are done in tandem
|
|
with a major point release of GitLab itself. All deprecations and changes
|
|
between two versions should be listed in the documentation. For the changes
|
|
between v3 and v4; please read the <a href="/v3_to_v4.md">v3 to v4 documentation</a></p>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#current-status" id="user-content-current-status"></a>Current status</h3>
|
|
<p dir="auto">Currently only API version v4 is available. Version v3 was removed in
|
|
<a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/36819" rel="nofollow noreferrer noopener" target="_blank">GitLab 11.0</a>.</p>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#basic-usage" id="user-content-basic-usage"></a>Basic usage</h2>
|
|
<p dir="auto">API requests should be prefixed with <code>api</code> and the API version. The API version
|
|
is defined in <a href="https://gitlab.com/gitlab-org/gitlab-ce/tree/master/lib/api/api.rb" rel="nofollow noreferrer noopener" target="_blank"><code>lib/api.rb</code></a>. For example, the root of the v4 API
|
|
is at <code>/api/v4</code>.</p>
|
|
<p dir="auto">Example of a valid API request using cURL:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="s2">"https://gitlab.example.com/api/v4/projects"</span></span></code></pre>
|
|
<p dir="auto">The API uses JSON to serialize data. You don't need to specify <code>.json</code> at the
|
|
end of an API URL.</p>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#authentication" id="user-content-authentication"></a>Authentication</h2>
|
|
<p dir="auto">Most API requests require authentication, or will only return public data when
|
|
authentication is not provided. For
|
|
those cases where it is not required, this will be mentioned in the documentation
|
|
for each individual endpoint. For example, the <a href="/projects.md"><code>/projects/:id</code> endpoint</a>.</p>
|
|
<p dir="auto">There are three ways to authenticate with the GitLab API:</p>
|
|
<ol dir="auto">
|
|
<li><a href="#oauth2-tokens">OAuth2 tokens</a></li>
|
|
<li><a href="#personal-access-tokens">Personal access tokens</a></li>
|
|
<li><a href="#session-cookie">Session cookie</a></li>
|
|
</ol>
|
|
<p dir="auto">For admins who want to authenticate with the API as a specific user, or who want to build applications or scripts that do so, two options are available:</p>
|
|
<ol dir="auto">
|
|
<li><a href="#impersonation-tokens">Impersonation tokens</a></li>
|
|
<li><a href="#sudo">Sudo</a></li>
|
|
</ol>
|
|
<p dir="auto">If authentication information is invalid or omitted, an error message will be
|
|
returned with status code <code>401</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight json" lang="json" v-pre="true"><code><span class="line" id="LC1" lang="json"><span class="p">{</span></span>
|
|
<span class="line" id="LC2" lang="json"><span class="w"> </span><span class="s2">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"401 Unauthorized"</span></span>
|
|
<span class="line" id="LC3" lang="json"><span class="p">}</span></span></code></pre>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#oauth2-tokens" id="user-content-oauth2-tokens"></a>OAuth2 tokens</h3>
|
|
<p dir="auto">You can use an <a href="/oauth2.md">OAuth2 token</a> to authenticate with the API by passing it in either the
|
|
<code>access_token</code> parameter or the <code>Authorization</code> header.</p>
|
|
<p dir="auto">Example of using the OAuth2 token in a parameter:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl https://gitlab.example.com/api/v4/projects?access_token<span class="o">=</span>OAUTH-TOKEN</span></code></pre>
|
|
<p dir="auto">Example of using the OAuth2 token in a header:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--header</span> <span class="s2">"Authorization: Bearer OAUTH-TOKEN"</span> https://gitlab.example.com/api/v4/projects</span></code></pre>
|
|
<p dir="auto">Read more about <a href="/oauth2.md">GitLab as an OAuth2 provider</a>.</p>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#personal-access-tokens" id="user-content-personal-access-tokens"></a>Personal access tokens</h3>
|
|
<p dir="auto">You can use a <a href="/user/profile/personal_access_tokens.md">personal access token</a> to authenticate with the API by passing it in either the
|
|
<code>private_token</code> parameter or the <code>Private-Token</code> header.</p>
|
|
<p dir="auto">Example of using the personal access token in a parameter:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl https://gitlab.example.com/api/v4/projects?private_token<span class="o">=</span>9koXpg98eAheJpvBs5tK</span></code></pre>
|
|
<p dir="auto">Example of using the personal access token in a header:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--header</span> <span class="s2">"Private-Token: 9koXpg98eAheJpvBs5tK"</span> https://gitlab.example.com/api/v4/projects</span></code></pre>
|
|
<p dir="auto">Read more about <a href="/user/profile/personal_access_tokens.md">personal access tokens</a>.</p>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#session-cookie" id="user-content-session-cookie"></a>Session cookie</h3>
|
|
<p dir="auto">When signing in to the main GitLab application, a <code>_gitlab_session</code> cookie is
|
|
set. The API will use this cookie for authentication if it is present, but using
|
|
the API to generate a new session cookie is currently not supported.</p>
|
|
<p dir="auto">The primary user of this authentication method is the web frontend of GitLab itself,
|
|
which can use the API as the authenticated user to get a list of their projects,
|
|
for example, without needing to explicitly pass an access token.</p>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#impersonation-tokens" id="user-content-impersonation-tokens"></a>Impersonation tokens</h3>
|
|
<blockquote dir="auto">
|
|
<p><a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9099" rel="nofollow noreferrer noopener" target="_blank">Introduced</a> in GitLab 9.0. Needs admin permissions.</p>
|
|
</blockquote>
|
|
<p dir="auto">Impersonation tokens are a type of <a href="/user/profile/personal_access_tokens.md">personal access token</a>
|
|
that can only be created by an admin for a specific user. They are a great fit
|
|
if you want to build applications or scripts that authenticate with the API as a specific user.</p>
|
|
<p dir="auto">They are an alternative to directly using the user's password or one of their
|
|
personal access tokens, and to using the <a href="#sudo">Sudo</a> feature, since the user's (or admin's, in the case of Sudo)
|
|
password/token may not be known or may change over time.</p>
|
|
<p dir="auto">For more information, refer to the
|
|
<a href="users.md#retrieve-user-impersonation-tokens">users API</a> docs.</p>
|
|
<p dir="auto">Impersonation tokens are used exactly like regular personal access tokens, and can be passed in either the
|
|
<code>private_token</code> parameter or the <code>Private-Token</code> header.</p>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#sudo" id="user-content-sudo"></a>Sudo</h3>
|
|
<blockquote dir="auto">
|
|
<p>Needs admin permissions.</p>
|
|
</blockquote>
|
|
<p dir="auto">All API requests support performing an API call as if you were another user,
|
|
provided you are authenticated as an administrator with an OAuth or Personal Access Token that has the <code>sudo</code> scope.</p>
|
|
<p dir="auto">You need to pass the <code>sudo</code> parameter either via query string or a header with an ID/username of
|
|
the user you want to perform the operation as. If passed as a header, the
|
|
header name must be <code>Sudo</code>.</p>
|
|
<p dir="auto">If a non administrative access token is provided, an error message will
|
|
be returned with status code <code>403</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight json" lang="json" v-pre="true"><code><span class="line" id="LC1" lang="json"><span class="p">{</span></span>
|
|
<span class="line" id="LC2" lang="json"><span class="w"> </span><span class="s2">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"403 Forbidden - Must be admin to use sudo"</span></span>
|
|
<span class="line" id="LC3" lang="json"><span class="p">}</span></span></code></pre>
|
|
<p dir="auto">If an access token without the <code>sudo</code> scope is provided, an error message will
|
|
be returned with status code <code>403</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight json" lang="json" v-pre="true"><code><span class="line" id="LC1" lang="json"><span class="p">{</span></span>
|
|
<span class="line" id="LC2" lang="json"><span class="w"> </span><span class="s2">"error"</span><span class="p">:</span><span class="w"> </span><span class="s2">"insufficient_scope"</span><span class="p">,</span></span>
|
|
<span class="line" id="LC3" lang="json"><span class="w"> </span><span class="s2">"error_description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"The request requires higher privileges than provided by the access token."</span><span class="p">,</span></span>
|
|
<span class="line" id="LC4" lang="json"><span class="w"> </span><span class="s2">"scope"</span><span class="p">:</span><span class="w"> </span><span class="s2">"sudo"</span></span>
|
|
<span class="line" id="LC5" lang="json"><span class="p">}</span></span></code></pre>
|
|
<p dir="auto">If the sudo user ID or username cannot be found, an error message will be
|
|
returned with status code <code>404</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight json" lang="json" v-pre="true"><code><span class="line" id="LC1" lang="json"><span class="p">{</span></span>
|
|
<span class="line" id="LC2" lang="json"><span class="w"> </span><span class="s2">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"404 User with ID or username '123' Not Found"</span></span>
|
|
<span class="line" id="LC3" lang="json"><span class="p">}</span></span></code></pre>
|
|
<hr/>
|
|
<p dir="auto">Example of a valid API call and a request using cURL with sudo request,
|
|
providing a username:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /projects?private_token=9koXpg98eAheJpvBs5tK&sudo=username</span></code></pre>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--header</span> <span class="s2">"Private-Token: 9koXpg98eAheJpvBs5tK"</span> <span class="nt">--header</span> <span class="s2">"Sudo: username"</span> <span class="s2">"https://gitlab.example.com/api/v4/projects"</span></span></code></pre>
|
|
<p dir="auto">Example of a valid API call and a request using cURL with sudo request,
|
|
providing an ID:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /projects?private_token=9koXpg98eAheJpvBs5tK&sudo=23</span></code></pre>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--header</span> <span class="s2">"Private-Token: 9koXpg98eAheJpvBs5tK"</span> <span class="nt">--header</span> <span class="s2">"Sudo: 23"</span> <span class="s2">"https://gitlab.example.com/api/v4/projects"</span></span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#status-codes" id="user-content-status-codes"></a>Status codes</h2>
|
|
<p dir="auto">The API is designed to return different status codes according to context and
|
|
action. This way, if a request results in an error, the caller is able to get
|
|
insight into what went wrong.</p>
|
|
<p dir="auto">The following table gives an overview of how the API functions generally behave.</p>
|
|
<table dir="auto">
|
|
<thead>
|
|
<tr>
|
|
<th>Request type</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>GET</code></td>
|
|
<td>Access one or more resources and return the result as JSON.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>POST</code></td>
|
|
<td>Return <code>201 Created</code> if the resource is successfully created and return the newly created resource as JSON.</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<code>GET</code> / <code>PUT</code>
|
|
</td>
|
|
<td>Return <code>200 OK</code> if the resource is accessed or modified successfully. The (modified) result is returned as JSON.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>DELETE</code></td>
|
|
<td>Returns <code>204 No Content</code> if the resource was deleted successfully.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p dir="auto">The following table shows the possible return codes for API requests.</p>
|
|
<table dir="auto">
|
|
<thead>
|
|
<tr>
|
|
<th>Return values</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>200 OK</code></td>
|
|
<td>The <code>GET</code>, <code>PUT</code> or <code>DELETE</code> request was successful, the resource(s) itself is returned as JSON.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>204 No Content</code></td>
|
|
<td>The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>201 Created</code></td>
|
|
<td>The <code>POST</code> request was successful and the resource is returned as JSON.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>304 Not Modified</code></td>
|
|
<td>Indicates that the resource has not been modified since the last request.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>400 Bad Request</code></td>
|
|
<td>A required attribute of the API request is missing, e.g., the title of an issue is not given.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>401 Unauthorized</code></td>
|
|
<td>The user is not authenticated, a valid <a href="#authentication">user token</a> is necessary.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>403 Forbidden</code></td>
|
|
<td>The request is not allowed, e.g., the user is not allowed to delete a project.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>404 Not Found</code></td>
|
|
<td>A resource could not be accessed, e.g., an ID for a resource could not be found.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>405 Method Not Allowed</code></td>
|
|
<td>The request is not supported.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>409 Conflict</code></td>
|
|
<td>A conflicting resource already exists, e.g., creating a project with a name that already exists.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>412</code></td>
|
|
<td>Indicates the request was denied. May happen if the <code>If-Unmodified-Since</code> header is provided when trying to delete a resource, which was modified in between.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>422 Unprocessable</code></td>
|
|
<td>The entity could not be processed.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>500 Server Error</code></td>
|
|
<td>While handling the request something went wrong server-side.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#pagination" id="user-content-pagination"></a>Pagination</h2>
|
|
<p dir="auto">Sometimes the returned result will span across many pages. When listing
|
|
resources you can pass the following parameters:</p>
|
|
<table dir="auto">
|
|
<thead>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>page</code></td>
|
|
<td>Page number (default: <code>1</code>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>per_page</code></td>
|
|
<td>Number of items to list per page (default: <code>20</code>, max: <code>100</code>)</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p dir="auto">In the example below, we list 50 <a href="/namespaces.md">namespaces</a> per page.</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--request</span> PUT <span class="nt">--header</span> <span class="s2">"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"</span> <span class="s2">"https://gitlab.example.com/api/v4/namespaces?per_page=50</span></span></code></pre>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#pagination-link-header" id="user-content-pagination-link-header"></a>Pagination Link header</h3>
|
|
<p dir="auto"><a href="http://www.w3.org/wiki/LinkHeader" rel="nofollow noreferrer noopener" target="_blank">Link headers</a> are sent back with each
|
|
response. They have <code>rel</code> set to prev/next/first/last and contain the relevant
|
|
URL. Please use these links instead of generating your own URLs.</p>
|
|
<p dir="auto">In the cURL example below, we limit the output to 3 items per page (<code>per_page=3</code>)
|
|
and we request the second page (<code>page=2</code>) of <a href="/notes.md">comments</a> of the issue
|
|
with ID <code>8</code> which belongs to the project with ID <code>8</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight shell" lang="shell" v-pre="true"><code><span class="line" id="LC1" lang="shell">curl <span class="nt">--head</span> <span class="nt">--header</span> <span class="s2">"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"</span> https://gitlab.example.com/api/v4/projects/8/issues/8/notes?per_page<span class="o">=</span>3&page<span class="o">=</span>2</span></code></pre>
|
|
<p dir="auto">The response will then be:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">HTTP/1.1 200 OK</span>
|
|
<span class="line" id="LC2" lang="plaintext">Cache-Control: no-cache</span>
|
|
<span class="line" id="LC3" lang="plaintext">Content-Length: 1103</span>
|
|
<span class="line" id="LC4" lang="plaintext">Content-Type: application/json</span>
|
|
<span class="line" id="LC5" lang="plaintext">Date: Mon, 18 Jan 2016 09:43:18 GMT</span>
|
|
<span class="line" id="LC6" lang="plaintext">Link: <https://gitlab.example.com/api/v4/projects/8/issues/8/notes?page=1&per_page=3>; rel="prev", <https://gitlab.example.com/api/v4/projects/8/issues/8/notes?page=3&per_page=3>; rel="next", <https://gitlab.example.com/api/v4/projects/8/issues/8/notes?page=1&per_page=3>; rel="first", <https://gitlab.example.com/api/v4/projects/8/issues/8/notes?page=3&per_page=3>; rel="last"</span>
|
|
<span class="line" id="LC7" lang="plaintext">Status: 200 OK</span>
|
|
<span class="line" id="LC8" lang="plaintext">Vary: Origin</span>
|
|
<span class="line" id="LC9" lang="plaintext">X-Next-Page: 3</span>
|
|
<span class="line" id="LC10" lang="plaintext">X-Page: 2</span>
|
|
<span class="line" id="LC11" lang="plaintext">X-Per-Page: 3</span>
|
|
<span class="line" id="LC12" lang="plaintext">X-Prev-Page: 1</span>
|
|
<span class="line" id="LC13" lang="plaintext">X-Request-Id: 732ad4ee-9870-4866-a199-a9db0cde3c86</span>
|
|
<span class="line" id="LC14" lang="plaintext">X-Runtime: 0.108688</span>
|
|
<span class="line" id="LC15" lang="plaintext">X-Total: 8</span>
|
|
<span class="line" id="LC16" lang="plaintext">X-Total-Pages: 3</span></code></pre>
|
|
<h3 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#other-pagination-headers" id="user-content-other-pagination-headers"></a>Other pagination headers</h3>
|
|
<p dir="auto">Additional pagination headers are also sent back.</p>
|
|
<table dir="auto">
|
|
<thead>
|
|
<tr>
|
|
<th>Header</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>X-Total</code></td>
|
|
<td>The total number of items</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>X-Total-Pages</code></td>
|
|
<td>The total number of pages</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>X-Per-Page</code></td>
|
|
<td>The number of items per page</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>X-Page</code></td>
|
|
<td>The index of the current page (starting at 1)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>X-Next-Page</code></td>
|
|
<td>The index of the next page</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>X-Prev-Page</code></td>
|
|
<td>The index of the previous page</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#namespaced-path-encoding" id="user-content-namespaced-path-encoding"></a>Namespaced path encoding</h2>
|
|
<p dir="auto">If using namespaced API calls, make sure that the <code>NAMESPACE/PROJECT_NAME</code> is
|
|
URL-encoded.</p>
|
|
<p dir="auto">For example, <code>/</code> is represented by <code>%2F</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /api/v4/projects/diaspora%2Fdiaspora</span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#branches-tags-name-encoding" id="user-content-branches-tags-name-encoding"></a>Branches & tags name encoding</h2>
|
|
<p dir="auto">If your branch or tag contains a <code>/</code>, make sure the branch/tag name is
|
|
URL-encoded.</p>
|
|
<p dir="auto">For example, <code>/</code> is represented by <code>%2F</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /api/v4/projects/1/branches/my%2Fbranch/commits</span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#id-vs-iid" id="user-content-id-vs-iid"></a><code>id</code> vs <code>iid</code>
|
|
</h2>
|
|
<p dir="auto">When you work with the API, you may notice two similar fields in API entities:
|
|
<code>id</code> and <code>iid</code>. The main difference between them is scope.</p>
|
|
<p dir="auto">For example, an issue might have <code>id: 46</code> and <code>iid: 5</code>.</p>
|
|
<table dir="auto">
|
|
<thead>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><code>id</code></td>
|
|
<td>Is unique across all issues and is used for any API call</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>iid</code></td>
|
|
<td>Is unique only in scope of a single project. When you browse issues or merge requests with the Web UI, you see the <code>iid</code>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p dir="auto">That means that if you want to get an issue via the API you should use the <code>id</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /projects/42/issues/:id</span></code></pre>
|
|
<p dir="auto">On the other hand, if you want to create a link to a web page you should use
|
|
the <code>iid</code>:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">GET /projects/42/issues/:iid</span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#data-validation-and-error-reporting" id="user-content-data-validation-and-error-reporting"></a>Data validation and error reporting</h2>
|
|
<p dir="auto">When working with the API you may encounter validation errors, in which case
|
|
the API will answer with an HTTP <code>400</code> status.</p>
|
|
<p dir="auto">Such errors appear in two cases:</p>
|
|
<ul dir="auto">
|
|
<li>A required attribute of the API request is missing, e.g., the title of an
|
|
issue is not given</li>
|
|
<li>An attribute did not pass the validation, e.g., user bio is too long</li>
|
|
</ul>
|
|
<p dir="auto">When an attribute is missing, you will get something like:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">HTTP/1.1 400 Bad Request</span>
|
|
<span class="line" id="LC2" lang="plaintext">Content-Type: application/json</span>
|
|
<span class="line" id="LC3" lang="plaintext">{</span>
|
|
<span class="line" id="LC4" lang="plaintext"> "message":"400 (Bad request) \"title\" not given"</span>
|
|
<span class="line" id="LC5" lang="plaintext">}</span></code></pre>
|
|
<p dir="auto">When a validation error occurs, error messages will be different. They will
|
|
hold all details of validation errors:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">HTTP/1.1 400 Bad Request</span>
|
|
<span class="line" id="LC2" lang="plaintext">Content-Type: application/json</span>
|
|
<span class="line" id="LC3" lang="plaintext">{</span>
|
|
<span class="line" id="LC4" lang="plaintext"> "message": {</span>
|
|
<span class="line" id="LC5" lang="plaintext"> "bio": [</span>
|
|
<span class="line" id="LC6" lang="plaintext"> "is too long (maximum is 255 characters)"</span>
|
|
<span class="line" id="LC7" lang="plaintext"> ]</span>
|
|
<span class="line" id="LC8" lang="plaintext"> }</span>
|
|
<span class="line" id="LC9" lang="plaintext">}</span></code></pre>
|
|
<p dir="auto">This makes error messages more machine-readable. The format can be described as
|
|
follows:</p>
|
|
<pre class="code highlight js-syntax-highlight json" lang="json" v-pre="true"><code><span class="line" id="LC1" lang="json"><span class="p">{</span></span>
|
|
<span class="line" id="LC2" lang="json"><span class="w"> </span><span class="s2">"message"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span></span>
|
|
<span class="line" id="LC3" lang="json"><span class="w"> </span><span class="s2">"<property-name>"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span></span>
|
|
<span class="line" id="LC4" lang="json"><span class="w"> </span><span class="s2">"<error-message>"</span><span class="p">,</span></span>
|
|
<span class="line" id="LC5" lang="json"><span class="w"> </span><span class="s2">"<error-message>"</span><span class="p">,</span></span>
|
|
<span class="line" id="LC6" lang="json"><span class="w"> </span><span class="err">...</span></span>
|
|
<span class="line" id="LC7" lang="json"><span class="w"> </span><span class="p">],</span></span>
|
|
<span class="line" id="LC8" lang="json"><span class="w"> </span><span class="s2">"<embed-entity>"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span></span>
|
|
<span class="line" id="LC9" lang="json"><span class="w"> </span><span class="s2">"<property-name>"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span></span>
|
|
<span class="line" id="LC10" lang="json"><span class="w"> </span><span class="s2">"<error-message>"</span><span class="p">,</span></span>
|
|
<span class="line" id="LC11" lang="json"><span class="w"> </span><span class="s2">"<error-message>"</span><span class="p">,</span></span>
|
|
<span class="line" id="LC12" lang="json"><span class="w"> </span><span class="err">...</span></span>
|
|
<span class="line" id="LC13" lang="json"><span class="w"> </span><span class="p">],</span></span>
|
|
<span class="line" id="LC14" lang="json"><span class="w"> </span><span class="p">}</span></span>
|
|
<span class="line" id="LC15" lang="json"><span class="w"> </span><span class="p">}</span></span>
|
|
<span class="line" id="LC16" lang="json"><span class="p">}</span></span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#unknown-route" id="user-content-unknown-route"></a>Unknown route</h2>
|
|
<p dir="auto">When you try to access an API URL that does not exist you will receive 404 Not Found.</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">HTTP/1.1 404 Not Found</span>
|
|
<span class="line" id="LC2" lang="plaintext">Content-Type: application/json</span>
|
|
<span class="line" id="LC3" lang="plaintext">{</span>
|
|
<span class="line" id="LC4" lang="plaintext"> "error": "404 Not Found"</span>
|
|
<span class="line" id="LC5" lang="plaintext">}</span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#encoding-in-iso-8601-dates" id="user-content-encoding-in-iso-8601-dates"></a>Encoding <code>+</code> in ISO 8601 dates</h2>
|
|
<p dir="auto">If you need to include a <code>+</code> in a query parameter, you may need to use <code>%2B</code> instead due
|
|
a <a href="http://www.w3.org/Addressing/URL/4_URI_Recommentations.html" rel="nofollow noreferrer noopener" target="_blank">W3 recommendation</a> that
|
|
causes a <code>+</code> to be interpreted as a space. For example, in an ISO 8601 date, you may want to pass
|
|
a time in Mountain Standard Time, such as:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">2017-10-17T23:11:13.000+05:30</span></code></pre>
|
|
<p dir="auto">The correct encoding for the query parameter would be:</p>
|
|
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span class="line" id="LC1" lang="plaintext">2017-10-17T23:11:13.000%2B05:30</span></code></pre>
|
|
<h2 dir="auto">
|
|
<a aria-hidden="true" class="anchor" href="#clients" id="user-content-clients"></a>Clients</h2>
|
|
<p dir="auto">There are many unofficial GitLab API Clients for most of the popular
|
|
programming languages. Visit the <a href="https://about.gitlab.com/applications/#api-clients" rel="nofollow noreferrer noopener" target="_blank" title="Clients using the GitLab API">GitLab website</a> for a complete list.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|