Skip to content

Quote curl example URLs in API docs

Greg Myers requested to merge api-docs-curl-example-quote-url into master

Problem to solve

API curl command examples containing ? in the URL will not produce the expected output executed in most terminals as bash/zsh ignores text after the &.

Example:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/application/settings?signup_enabled=false&default_project_visibility=internal

when copy/pasted to a terminal will actually interpret the endpoint URL to stop at the & character and the &default_project_visibility=internal filters will not be applied.

Without encapsulating the URL in quotes, the output received is actually for:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/application/settings?signup_enabled

Proposal:

Encapsulate URLs in quotes for API curl command examples. With the URL in quotes, the shell will send the intended request, not stop at the & in the URL

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/application/settings?signup_enabled=false&default_project_visibility=internal"

🎉

What does this MR do?

Most of all:

  • Encapsulate URLs in quotes for API curl command examples.
  • Closes #216603 (closed)

Additionally:

  • in a few situations where Private-Token was in single-quotes but URL would be in double quotes, I standardized on double quotes to prevent mixed quotes
  • found a few look-alike Private-Tokens in the docs examples instead of <your_access_token>, I removed the look-alike and replaced it with <your_access_token> (inspired by @axil 0e078d1a)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

WDYT? @axil @sselhorn @aqualls @mjang1

Edited by 🤖 GitLab Bot 🤖

Merge request reports