How to use std.http properly

Hi,

I’m trying to get familiar with the Zig language.
For that I’ve choosen a project for some Oauth2 authentication.
This relies heavily on the http communication.

At least I try to put this

curl --request POST \
--url {your-domain}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=${code} \
--data redirect_uri=${redirect_uri} \
--data client_id=${client_id} \
--data code_verifier=${code_verifier}

into some Zig code.

I’m struggling setting the data. Setting the header is no problem. But I got no idea how to set the data.

I suppose I’m kinda blindfold.
So maybe somebody can point me into the right direction.
And no; Google so far wasn’t my friend.

Any help is really appreciated.

BR SMF

Dev System: Win 11 23H2 with WSL, Podman (Docker) container in WSL, Host OS Almalinux 9.4, Guest OS Almalinux 9.4, VSCode, Devcontainers, Zig Master, ZLS current

Hello @mf-in-mun, welcome to ziggit!

Maybe this answer that was also about curl can help a bit:

I think especially the option --trace-ascii output-file.txt is a good first step to replicate something similar using zig.