• Creator
  • #4142561

    Powershell SOAP for ServiceNow

    by srikanthbollu1707 ·

    I am trying to use Powershell SOAP to create a ticket in ServiceNow. I have valid XML that I have successfully tested with the SoapUI tool using basic auth. But when I try to post that same XML to ServiceNow via Powershell I get an error. I’m not sure if its a problem with the auth header (same creds in both SoapUI and PS) or something else because I’m getting a 500 error from the post, which doesn’t sound auth related.

You are posting a reply to: Powershell SOAP for ServiceNow

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

  • Author
    • #4154606

      Reply To: Powershell SOAP for ServiceNow

      by shelly5990 ·

      In reply to Powershell SOAP for ServiceNow

      Troubleshooting SOAP requests and responses can be a bit complex, but let’s break down the common issues and steps you can take to troubleshoot the problem.

      1. Check Request Headers and Body: Ensure that the headers you’re sending in PowerShell are correctly formatted and match the headers you successfully used in SoapUI. Also, double-check that the XML payload is exactly the same as the one that worked in SoapUI.

      2. Debugging PowerShell Script: Add detailed debugging output to your PowerShell script so you can examine the request and response more closely. This can help you identify where the issue might be. You can use Invoke-RestMethod with the -Debug flag to get verbose debugging information.

      powershellCopy code

      $Headers = @{
      “Authorization” = “Basic ” + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(“username:password”))
      “Content-Type” = “text/xml; charset=utf-8″

      $XMLPayload = @”
      <!– Your XML content here –>

      $url = “;

      $response = Invoke-RestMethod -Uri $url -Method Post -Headers $Headers -Body $XMLPayload -Debug

      3. Check HTTP Status Codes: The 500 Internal Server Error doesn’t necessarily mean it’s not an authentication issue. It can indicate a server-side issue, but it can also be due to incorrect XML format or other problems with the request. Make sure to analyze the full response, including the headers and the response body, to get more insight.

      4. Authentication: Although you mentioned that you’re using the same credentials in both SoapUI and PowerShell, make sure you’re constructing the “Authorization” header correctly. The format should be Basic base64(username:password).

      5. Error Handling: Wrap your PowerShell code in a try-catch block to capture any errors that might occur during the request and response handling. This will help you catch any exceptions and display more meaningful error messages.

      powershellCopy code

      try {
      # Your SOAP request code here
      } catch {
      Write-Host “An error occurred: $_”

      6. Contact ServiceNow Support: If you’ve tried all the above steps and are still encountering the issue, it might be worth reaching out to ServiceNow support. They can provide specific guidance on any known issues or configuration details that could be causing the problem.

      Remember that troublesh

Viewing 0 reply threads