web service error: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Script.CallWebService(XmlDocument xmlDocSoapEnvelope, String uriSoap) (Script 'WebAPIv1_RequestWithSoapBody')
What are some common reasons why this happens so I know how best to debug my code. This is done with soap.
Hi Curtis
It is difficult to say what exactly goes wrong for the request you are sending. Most likely there is a formatting issue in the SOAP or in the headers. What is the actual error you are receiving? There should be a faultcode & faultstring available in the response from the server.
I have an example here that executes a script with 1 parameter:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ExecuteAutomationScriptWithOutput xmlns="http://www.skyline.be/api/v1">
<connection>CONNECTION_GUID</connection>
<script>
<Name>Echo</Name>
<Folder></Folder>
<Description></Description>
<Settings>
<RequireInteractive>false</RequireInteractive>
<HasFindInteractiveClient>false</HasFindInteractiveClient>
</Settings>
<Parameters>
<DMAAutomationScriptParameter>
<ParameterId>1</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>param1</Name>
<Value>test</Value>
</DMAAutomationScriptParameter>
</Parameters>
<Dummies>
</Dummies>
<MemoryFiles>
</MemoryFiles>
</script>
<scriptOptions>
<WaitForScript>true</WaitForScript>
<CheckSets>true</CheckSets>
<LockElements>false</LockElements>
<ForceLockElements>false</ForceLockElements>
<WaitWhenLocked>true</WaitWhenLocked>
<IsInUse>false</IsInUse>
<AskForConfirmation>false</AskForConfirmation>
</scriptOptions>
</ExecuteAutomationScriptWithOutput >
</soap:Body>
</soap:Envelope>
This is my soap body but I am still getting a 500 error. Is there anything that you think I have done wrong here.
<ExecuteAutomationScriptWithOutput xmlns="http://www.skyline.be/api/v1">
<connection>xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx</connection>
<script>
<Name>GetHistoricalAlarms</Name>
<Folder></Folder>
<Description></Description>
<Settings>
<RequireInteractive>false</RequireInteractive>
<HasFindInteractiveClient>false</HasFindInteractiveClient>
</Settings>
<Parameters>
<DMAAutomationScriptParameter>
<ParameterId>1</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>lStartTime</Name>
<Value>1727195089000</Value>
</DMAAutomationScriptParameter>
<DMAAutomationScriptParameter>
<ParameterId>2</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>lEndTime</Name>
<Value>1727195329000</Value>
</DMAAutomationScriptParameter>
<DMAAutomationScriptParameter>
<ParameterId>3</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>sIncludeInformationEvents</Name>
<Value>false</Value>
</DMAAutomationScriptParameter>
<DMAAutomationScriptParameter>
<ParameterId>4</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>sIncludeEntireAlarmTree</Name>
<Value>false</Value>
</DMAAutomationScriptParameter>
<DMAAutomationScriptParameter>
<ParameterId>5</ParameterId>
<Values xsi:nil="true" />
<MemoryFile></MemoryFile>
<Name>sJoinedSeverities</Name>
<Value></Value>
</DMAAutomationScriptParameter>
</Parameters>
<Dummies></Dummies>
<MemoryFiles></MemoryFiles>
</script>
<scriptOptions>
<WaitForScript>true</WaitForScript>
<CheckSets>true</CheckSets>
<LockElements>false</LockElements>
<ForceLockElements>false</ForceLockElements>
<WaitWhenLocked>true</WaitWhenLocked>
<IsInUse>false</IsInUse>
<AskForConfirmation>false</AskForConfirmation>
</scriptOptions>
</ExecuteAutomationScriptWithOutput>
Just to point out, my remote script has no description and is located in the default Automation Scripts folder
Hi Curtis, there doesn't seem to be anything wrong with the XML at first sight. Can you share what error message you receive with the error 500?
web service error: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Script.CallWebService(XmlDocument xmlDocSoapEnvelope, String uriSoap) (Script 'XXXXXXX')
This looks like the error that is thrown by your code calling the SOAP endpoint. Is there anything inside the actual response that causes the error? You can check this by catching the error and looking at the InnerException/Message/Response properties of the WebException (https://learn.microsoft.com/en-us/dotnet/api/system.net.webexception?view=net-9.0#properties).
okay will try to catch the error but want to as. Is there anything I will need to set in the script being triggered remotely for it to be able to send an output
or if anyone can give an example of how to use the soap method ExecuteAutomationScriptWithOutput in a soap envelope do share