diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-07-12 14:08:00 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-07-12 14:08:00 +0300 |
commit | 94627fd7e3b4010e12f7a0698494b2c36c4f76ef (patch) | |
tree | 27b1254115fe185ba488eebf67fd88105567eca3 /doc | |
parent | 6f8cf37ebeaa0098072df66e556b6c59de531734 (diff) | |
parent | edf1945f3815d1bd8d2fe6a91e3c3c132e1b02ff (diff) |
Merge branch 'docs-add-api-params-array-hash' into 'master'
Add examples for array and hash type API params
See merge request gitlab-org/gitlab-ce!20574
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/README.md | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/doc/api/README.md b/doc/api/README.md index 6267618d3bc..4566319ad45 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -388,7 +388,7 @@ For example, `/` is represented by `%2F`: GET /api/v4/projects/diaspora%2Fdiaspora ``` -## Branches & tags name encoding +## Branches and tags name encoding If your branch or tag contains a `/`, make sure the branch/tag name is URL-encoded. @@ -399,6 +399,36 @@ For example, `/` is represented by `%2F`: GET /api/v4/projects/1/branches/my%2Fbranch/commits ``` +## Encoding API parameters of `array` and `hash` types + +When making an API call with parameters of type `array` and/or `hash`, the parameters may be +specified as shown below. + +### `array` + +`import_sources` is a parameter of type `array`: + +``` +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \ +-d "import_sources[]=github" \ +-d "import_sources[]=bitbucket" \ +"https://gitlab.example.com/api/v4/some_endpoint +``` + +### `hash` + +`override_params` is a parameter of type `hash`: + +``` +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \ +--form "namespace=email" \ +--form "path=impapi" \ +--form "file=@/path/to/somefile.txt" +--form "override_params[visibility]=private" \ +--form "override_params[some_other_param]=some_value" \ +https://gitlab.example.com/api/v4/projects/import +``` + ## `id` vs `iid` When you work with the API, you may notice two similar fields in API entities: |