Any way to automate getting curl request from failed test?

My question:

Is there a way to automate getting curl from failed tests?
Is there a way to access curl, maybe save it to a variable and display the variable value?