This is what Pester is for.
Get started with Pester (PowerShell unit testing framework)
Are you saying, you’ve tried to use the above tool and not proven successful for your use case / needs?
Or that you could not derive a way you felt prudent with it?
Ensure you are doing some error handling as well.
Error Handling for Invoke-RestMethod - PowerShell