Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a731a346
Commit
a731a346
authored
Aug 09, 2018
by
Alexander
Committed by
Marcia Ramos
Aug 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "docs update api for usage with an array of hashes"
parent
981fbc21
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
doc/api/README.md
doc/api/README.md
+17
-4
No files found.
doc/api/README.md
View file @
a731a346
...
@@ -401,14 +401,13 @@ GET /api/v4/projects/1/branches/my%2Fbranch/commits
...
@@ -401,14 +401,13 @@ GET /api/v4/projects/1/branches/my%2Fbranch/commits
## Encoding API parameters of `array` and `hash` types
## 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
We can call the API with
`array`
and
`hash`
types parameters as shown below:
specified as shown below.
### `array`
### `array`
`import_sources`
is a parameter of type
`array`
:
`import_sources`
is a parameter of type
`array`
:
```
```
bash
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
\
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
\
-d
"import_sources[]=github"
\
-d
"import_sources[]=github"
\
-d
"import_sources[]=bitbucket"
\
-d
"import_sources[]=bitbucket"
\
...
@@ -419,7 +418,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
...
@@ -419,7 +418,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
`override_params`
is a parameter of type
`hash`
:
`override_params`
is a parameter of type
`hash`
:
```
```
bash
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
\
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
\
--form
"namespace=email"
\
--form
"namespace=email"
\
--form
"path=impapi"
\
--form
"path=impapi"
\
...
@@ -429,6 +428,20 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
...
@@ -429,6 +428,20 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" \
https://gitlab.example.com/api/v4/projects/import
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`
## `id` vs `iid`
When you work with the API, you may notice two similar fields in API entities:
When you work with the API, you may notice two similar fields in API entities:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment