Powershell app can be used to invoke any HTTP request. We demonstrate this by invoking a sample GET request and demonstrating the use of the JSON Parser node to parse the response body.
The Invoke-WebRequest commandlet in Powershell is used to call the Freshservice ticket details API. The response JSON is parsed using the JSON parser node in the Automator, which yields the parsed JSON response, and the key-values of the parsed JSON can be used in subsequent nodes in the Automator.
Step 1: : Invoke the Web request using the commandlet Invoke-WebRequest 4
The command used to call the Freshservice REST API
$credPair = "<your-freshservice-api-token>:.";
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair));
$headers = @{ Authorization = "Basic $encodedCredentials" };
$url = "https://<your-subdomain>.freshservice.com/api/v2/tickets/1?include=assets";
$Response = Invoke-WebRequest -Uri $url -Method Get -Headers $headers -UseBasicParsing;
$Response.Content;
Step 2: Test the action and copy the sample response body to the clipboard.
Step 3: Drag and drop the JSON Parser node onto the canvas
Step 4: Map the Source to the output of the Powershell App action
Step 5: Paste the sample response body into the Payload section and hit the Generate Output button to automatically create the outputs based on the schema of the payload input.
Optional: If you require any other values from the schema at runtime, you can also create your outputs with custom JSON Path expressions.
Step 6: Reference any outputs configured in the Parser nodes in subsequent conditions and actions going forward.