Skip to content
Snippets Groups Projects
Commit a731a346 authored by Alexander's avatar Alexander Committed by Marcia Ramos
Browse files

Resolve "docs update api for usage with an array of hashes"

parent 981fbc21
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -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" \
Loading
Loading
@@ -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" \
Loading
Loading
@@ -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:
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment