Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
EV Contributor.
Contributor.
314 views

Scripting: Send post request from c# rule.

Jump to solution

Hi.

I try this code (for example) on visual studio, its work

string url = "http://upread.ru/save.php";
            {var webClient = new WebClient();
                var pars = new NameValueCollection();
                pars.Add("message""text of message");
                var response = webClient.UploadValues(url, pars);
                string str = System.Text.Encoding.UTF8.GetString(response);
                Console.WriteLine(str);
            }

but in HP SV i have error:

IsException: True
Exception: HP.SV.Runtime.Simulation.DataSimulator.ServiceOperationRule.CSharp.CSharpRuleException
Message: C# rule New Rule 3 execution failed with error ArgumentException
HelpLink:
Source: HP.SV.Runtime.Simulation.DataSimulator

Anyone can help me?

0 Likes
1 Solution

Accepted Solutions
Jakub Honored Contributor.
Honored Contributor.

Re: Scripting: Send post request from c# rule.

Jump to solution

My guess is you have C# Sandbox enabled and it is restricting you from sending a HTTP request. Try to disable it in the app.config. The help is here: https://admhelp.microfocus.com/sv/en/5.0/Help/Content/UG/t_scripted_rule_Csharp.htm#mt-item-0

If you have already disabled the sandbox (or added permission), please try to run check the log file for more details. Logs are located here: https://admhelp.microfocus.com/sv/en/5.0/Help/Content/UG/c_logs.htm and let me know what you find.

Thanks.

---
Service Virtualization R&D
0 Likes
2 Replies
Jakub Honored Contributor.
Honored Contributor.

Re: Scripting: Send post request from c# rule.

Jump to solution

My guess is you have C# Sandbox enabled and it is restricting you from sending a HTTP request. Try to disable it in the app.config. The help is here: https://admhelp.microfocus.com/sv/en/5.0/Help/Content/UG/t_scripted_rule_Csharp.htm#mt-item-0

If you have already disabled the sandbox (or added permission), please try to run check the log file for more details. Logs are located here: https://admhelp.microfocus.com/sv/en/5.0/Help/Content/UG/c_logs.htm and let me know what you find.

Thanks.

---
Service Virtualization R&D
0 Likes
EV Contributor.
Contributor.

Re: Scripting: Send post request from c# rule.

Jump to solution

Thank you, it's work

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.