api-sandbox/share/readmes/curl.md
2025-04-22 18:06:11 +03:00

1.4 KiB

Multiple header values

when you have more than one header value, ie you want to pass the authentication token and you want to pass json values

simply state each header value separately while preceeding it with the -H/--header prefix

e.g.

-H "Authentication: Bearer 2342343" \ -H "Content-Type: application/json"

note the forward slash \ is used to separate between lines for readability

Passing the Authentication token

get an authentication token from the server then pass it in through the header

--header "Authorization: Bearer <token>

Passing Json Values Through Curl

step 1 - set the header

--header "Content-Type: application/json"

step 2 - encode the values

-d "{\"name\":\"$2\", \"code\":\"$3\"}"

the bracketed area must be enclose with double quotes (single could work, but we need to change the parameters into strings, and bash does not seem to do that with singles)

the parameter names and values must also be enclosed in backslashed double quotes

\"

this means the entire string has to be enclosed in normal doubles instead of singles to interpolate the values

various

how can i set the request header for curl

curl snippets

interpolate

insert (something of a different nature) into something else.