First, you need to create an Endpoint for the Export By Scenario page.
Go to Web Service Endpoints (SM207060) page and extend any existing endpoint.
Add a new Endpoint and map it to the Export By Scenario page.

Add the Name and Status of the Scenario as a parameter.

Prepare and Export is starting long operation, in order to get the correct file you will need to do a get request and check if the Status is completed.
Add action under endpoint and map it to prepareExport action of the graph.

Add the Name of the scenario as a parameter of the Action.
Now is time for the action.
Below is example code how to invoke the our action on the “Export AP Vendors” export scenario.
var client = new RestClient("http://localhost/ACU19200/entity/DefaultExt/18.200.001/ExportByScenarios/prepareExport");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n\t\"entity\":{\n\t\t\"Name\" : {\"value\":\"Export AP Vendors\"}\n\t},\n\t\"parameters\":{\n\t\t\n\t}\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
As a result, you will get 202 Response Code if everything has been handled correctly.
Now we need to check if the scenario has worked and the file is export.
var client = new RestClient("http://localhost/ACU19200/entity/DefaultExt/18.200.001/ExportByScenarios/Export AP Vendors");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
As a response to this request you will get the Record of the Scenario, something like below:
{
"id": "730d3b2c-d87f-e411-beca-00b56d0561c2",
"rowNumber": 1,
"note": "",
"Name": {
"value": "Export AP Vendors"
},
"Status": {
"value": "Processed"
},
"custom": {},
"files": [
{
"id": "9479c468-1cfa-4fb5-b8bd-30c10535e525",
"filename": "Data Providers (Export AP Vendors)\\AP Export Vendor Template.xlsx",
"href": "/ACU19200/entity/DefaultExt/18.200.001/files/9479c468-1cfa-4fb5-b8bd-30c10535e525"
}
]
}
Now you need to take the “id” from the files section and get that file
var client = new RestClient("http://localhost/ACU19200/entity/DefaultExt/18.200.001/files/9479c468-1cfa-4fb5-b8bd-30c10535e525");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
As a result, you will get the file as application/octet-stream.