Re: How to dynamically generate UUID in curl command (like macros) before sending http request?

Timothe Litt via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
What OS?

On most Linux/Unix, use uuidgen.

curl -X POST -H "x-client-request-id: {$(uuidgen)}" -d '{"a": 1}' 
https:/example.com <http://example.com>

If you need it for subsequent requests, use

UUID="{$(uuidgen)}"

curl -X POST -H "x-client-request-id: ${UUID}" -d '{"a": 1}' 
https:/example.com <http://example.com>

and insert $UUID in the cookie/uri/whatever you need for those requests.

Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.

On 24-May-24 13:46, Евгений Морозов via curl-users wrote:
> I want to send POST http request via curl in Windows command line app.
> There is *x-client-request-id* header in request
> I want to create curl command that dynamically generate UUID for this 
> header
>
> Something like that:
> curl -X POST -H "x-client-request-id: {{UUID}}" -d '{"a": 1}' 
> https:/example.com <http://example.com>
>
> This doesn't work:
> ${uuid}
> {{$uuid}}
>
>
> --
> James Frost
>

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
OpenPGP_signature.asc (application/pgp-signature, 495 B)
-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEE0UvvF0GpbrNhifE5DTaRiR4XoSQFAmZQ4eQFAwAAAAAACgkQDTaRiR4XoSRY
eggAt31yJHzheat6GbVPx8XjxriSt4djCPQik8f6KtaRvyRw86IS8x2Q1U0mEWK8oxQ0RipJ7cIs
HGSR/95nGWS56gIKItS1f2RmaQFO+VBDnH4aAMxCMKQrmg6APfL41TS9o+8oqg6PLlZ99edH3Lej
jAqN7MhBXUVhYBZpjQ1pL8pFL1MNog1GokNg7rLgWVHdB7+qo2sWGjQnftI8roTlUssk+rsEjLmf
ybWJ3BVkda63qvyJVEnxX85Oye6yEl4vwFu2cBHVKzwqFH0OHwRQv4/4TdXXmIV1sRqh8GIXSLp3
6//4uLWaei4U8gpBmJwjoSIJTgi37C8Tx/w2P2IpeQ==
=opgv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.