C# 邮递员-如何从列表传递数据<;字符串>;,在内存中,输入Newman命令行的数据部分

C# 邮递员-如何从列表传递数据<;字符串>;,在内存中,输入Newman命令行的数据部分,c#,console-application,postman,newman,postman-collection-runner,C#,Console Application,Postman,Newman,Postman Collection Runner,我需要从我的C#方法中执行Postman集合。 但是我需要直接从方法输出(如列表)传递数据,而不是数据文件 这是我的密码: public StringBuilder RunPostmanCall(string collectionPath, string executionFolder, string environmentPath, List<string> inputFilePath = null) { StringBuilder run

我需要从我的C#方法中执行Postman集合。 但是我需要直接从方法输出(如列表)传递数据,而不是数据文件

这是我的密码:

 public StringBuilder RunPostmanCall(string collectionPath, string executionFolder, string environmentPath, List<string> inputFilePath = null)
        {
            StringBuilder runOutputBuilder = new StringBuilder();
            string runOutput = null;
            ProcessStartInfo psiNpm = new ProcessStartInfo
            {
                FileName = "cmd",
                RedirectStandardOutput = true,
                RedirectStandardInput = true,
                UseShellExecute = false
            };
            Process pNpmRun = Process.Start(psiNpm);
            pNpmRun.OutputDataReceived += (sender, a) => runOutputBuilder.AppendLine(a.Data);
            Console.WriteLine("   - Install Newman ...");
            pNpmRun.StandardInput.WriteLine($"npm install -g newman");
            Console.WriteLine("   - Execute Postman Script ...");
            string value = $"newman run " +
                $"\"" + collectionPath + "\" " +
                $"--folder \"" + executionFolder + "\" " +
                $"--environment \"" + environmentPath + "\" " +
                $"-d \"" + inputFilePath + "\" " +
                $"--disable-unicode";
            pNpmRun.StandardInput.WriteLine(value);
            pNpmRun.BeginOutputReadLine();
            pNpmRun.StandardInput.WriteLine("exit 0");


我可以将输出保存到文件中,然后在命令行中使用该文件位置。但我希望避免创建文件,而直接从内存读取数据。

不幸的是,使用-d只能引用文件系统中的文件

如果您不愿意将这些数据直接写入文件,我建议您直接将这些值设置为命令行中的全局变量。 尝试将此参数添加到newman run命令中
--global var key=value


您可以将数据添加到字符串中,并将其作为全局变量添加。您可以在预请求或测试脚本中正常解析它。

不确定是否支持该功能,但可以临时写入文件,运行newman,然后删除该文件?Hi@so cal cheesehead,该临时文件存储在哪里?它应该从Azure WebJob运行,我不希望在blob中创建任何新文件(即使是临时文件)。很抱歉,我不熟悉Azure WebJob,我认为它可能在本地或服务器上运行
bin\Debug>newman run "../../api/postman_audit.json" --folder "SearchIndex" --environment "../../api/postman_environment.json" -d "System.Collections.Generic.List`1[System.String]" --disable-unicode