Then, do the thing. Once you have done the thing, look for the network call that actually did the action (usually a GET or a POST) (it may be helpful to clear the network tab just before you do the action to help narrow down what you are looking for).
Right-click it and choose "copy" -> "copy as cURL"
Open Postman (a free tool for calling api's directly and repeatedly). At the top left, click Import and then choose "Paste Raw Text"
"BUT WAIT!" you say? Yeah, I saw that too. I think that's a bug in Postman. The action says "GET", but we gave it a "POST". Go on about your bad self and just change that.
You now have that call as a Postman interface. You can choose the Headers tab and manipulate what's in there, or Body, there may be things in there. Different web sites require different headers, so we usually just experiment there.
Once you have that configured how you want, you can export the call as code. Look for the word "Code" in the upper right of the Postman screen and then you can choose from many different languages.
Tada! Now just copy that code and paste it into your favorite editor.