diff options
author | Alexander <astrachan@gitlab.com> | 2018-08-09 09:38:43 +0000 |
---|---|---|
committer | Marcia Ramos <virtua.creative@gmail.com> | 2018-08-09 09:38:43 +0000 |
commit | a731a3468ec8456d40ef86722fdc4e19e658d9fb (patch) | |
tree | 9d30c0d8b6dcce949bbf622423297fa4b99b9896 /doc/api/README.md | |
parent | 981fbc21b05638fa14911ee8fe8bc3fb39c025b8 (diff) | |
download | gitlab-ce-a731a3468ec8456d40ef86722fdc4e19e658d9fb.tar.gz |
Resolve "docs update api for usage with an array of hashes"
Diffstat (limited to 'doc/api/README.md')
-rw-r--r-- | doc/api/README.md | 21 |
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: |