summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcia Ramos <virtua.creative@gmail.com>2018-08-09 09:38:43 +0000
committerJose Vargas <jvargas@gitlab.com>2018-08-09 12:01:46 -0500
commit0cdddba62e9291f6214576331790b8d0bb3fead5 (patch)
tree540301e7b9583d3d11878bc1759b4fe08c947e8e
parent2b92a56f12e761c158e091962d065a348a40c027 (diff)
downloadgitlab-ce-0cdddba62e9291f6214576331790b8d0bb3fead5.tar.gz
Merge branch '49821-docs-update-api-for-usage-with-an-array-of-hashes' into 'master'
Resolve "docs update api for usage with an array of hashes" Closes #49821 See merge request gitlab-org/gitlab-ce!20952
-rw-r--r--doc/api/README.md21
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/api/README.md b/doc/api/README.md
index 4566319ad45..45e926d3b6b 100644
--- a/doc/api/README.md
+++ b/doc/api/README.md
@@ -401,14 +401,13 @@ 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.
+We can call the API with `array` and `hash` types parameters as shown below:
### `array`
`import_sources` is a parameter of type `array`:
-```
+```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
-d "import_sources[]=github" \
-d "import_sources[]=bitbucket" \
@@ -419,7 +418,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
`override_params` is a parameter of type `hash`:
-```
+```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
--form "namespace=email" \
--form "path=impapi" \
@@ -429,6 +428,20 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
https://gitlab.example.com/api/v4/projects/import
```
+### Array of hashes
+
+`variables` is a parameter of type `array` containing hash key/value pairs `[{ 'key' => 'UPLOAD_TO_S3', 'value' => 'true' }]`:
+
+```bash
+curl --globoff --request POST --header "PRIVATE-TOKEN: ********************" \
+"https://gitlab.example.com/api/v4/projects/169/pipeline?ref=master&variables[][key]=VAR1&variables[][value]=hello&variables[][key]=VAR2&variables[][value]=world"
+
+curl --request POST --header "PRIVATE-TOKEN: ********************" \
+--header "Content-Type: application/json" \
+--data '{ "ref": "master", "variables": [ {"key": "VAR1", "value": "hello"}, {"key": "VAR2", "value": "world"} ] }' \
+"https://gitlab.example.com/api/v4/projects/169/pipeline"
+```
+
## `id` vs `iid`
When you work with the API, you may notice two similar fields in API entities: