Save output of HTTP Response and payload into separate .txt files

Hi,

I’m want to save output in 2 saperate file, one for http response and other one for payload in .txt files. Below is my code I want to have some idea to get output in .txt files

$Url = " https//...."
$Body = @{
Id = " ... ";
tokenApi = " .... "
} | ConvertTo-Json
$Params = @{
Uri = $Url;
Method = 'POST';
Body = $Body;
ContentType = 'application/json' }
$Response = Invoke-RestMethod @Params
$Token = $Response.token

$Url = " https//...."
$Header = @{
Authorization = "Bearer $Token"
}
$Body = @{
gatewayId = " ...."
} | ConvertTo-Json
$Params = @{
Uri = $Url;
Header = $Header;
Method = 'POST';
Body = $Body;
ContentType = 'application/json' }
$Response = Invoke-RestMethod @Params
$Response

Thanks in advance.

You will have to give more info. What is the output of the rest call ? Can you share us a sample output ?
What do yo mean by payload here ?

btwn, you don’t need to use semicolon at the end of the line, PowerShell doesn’t need it to be there :slight_smile:

After rest call my out put is “status 200” or "failed with 401 ".