I have a script to insure that all the API controllable parameters have the values we want. It has worked fine so far, but the developers are really bad at documenting their new additions to that part of the API
In GitLab 13.1, repository_storages_weighted
was added, being the first hash supposedly controllable there.
Currently we only have one type of storage, so we currently don’t need to be able to set this, but that might change in a few months time (We have bought some S3 compatible storage, and I have a task to make GitLab use that. Artifacts and repositories are first in line though).
But I’m having a hard time getting my script to support hashes. It seems that whatever (semi-sane) I do the API just replies “400” (“Bad Request”).
So I decided to do some manual requests hoping to gain some insight into what works and what don’t, but so far it has just confused me more.
I’m using information from
https://docs.gitlab.com/ee/api/settings.html
which (of relevance to this question) basically says that I have to do PUT
's to the url, to change settings in this part of the API.
Combined with infomation from
https://docs.gitlab.com/ee/api/README.html#encoding-api-parameters-of-array-and-hash-types
which tries to tell how to encode hashes (and arrays, but those work).
Here is some in+output (the actual token has been removed, and I’ve edited the output, that would show all our settings, as that is completely irrelevant, if someone thinks otherwise, explain and I’ll provide it), showing the problem:
grove@gitlab2> curl --include --insecure --header 'PRIVATE-TOKEN: ’ -X PUT ‘https://localhost/api/v4/application/settings’ --form ‘issues_create_limit=301’
HTTP/2 200
server: nginx
date: Tue, 01 Sep 2020 14:06:57 GMT
content-type: application/json
content-length: 7234
vary: Accept-Encoding
cache-control: max-age=0, private, must-revalidate
etag: W/“0808614f41f9cf5f4d076ecb206d8b97”
vary: Origin
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-request-id: 76OEE1KTKla
x-runtime: 0.201272
strict-transport-security: max-age=31536000
referrer-policy: strict-origin-when-cross-origin
{“id”:1,[…removed for lack of relevance…]}
grove@gitlab2> curl --insecure --include --header 'PRIVATE-TOKEN: ’ --request PUT ‘https://localhost/api/v4/application/settings’ --form ‘repository_storages_weighted[default]=301’
HTTP/2 400
server: nginx
date: Tue, 01 Sep 2020 14:12:29 GMT
content-type: application/json
content-length: 88
cache-control: no-cache
vary: Origin
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-request-id: DbCv0RO8jp7
x-runtime: 0.297471
Is this some instance of some subtle difference between how PUT
and POST
works, that I’m not aware of, or what am I doing wrong. And how do I make a request to the API changing this value?