curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

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

From: Ray Satiro via curl-users <curl-users_at_lists.haxx.se>
Date: Fri, 24 May 2024 15:16:15 -0400

On 5/24/2024 2:52 PM, Timothe Litt via curl-users wrote:
>
> 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.
>

Some uuidgen will not be really random unless you use uuidgen -r I
think. Also, this guy asked the same question in the discussions
section. [1]

[1]: https://github.com/curl/curl/discussions/13768


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2024-05-24