Create ServiceNow task using Powershell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 12:47 PM
As part of my development work, I have to create ServiceNow task through PowerShell. I have retrieved the WSDL for the SOAP end point using the url
https://johndeere.service-now.com/sc_task.do?WSDL.
Using the info I created a SOAP body, but I am getting a weird error - Failed to connect to SNOW and/or verify soap note. Return status code is: 500
Url: https://company.service-now.com/sc_task.do?SOAP
ACTION: http://www.service-now.com/sc_task/insert
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:tsk='http://www.service-now.com/sc_task'>
<soapenv:Header/>
<soapenv:Body>
<tsk:insert>
<!--Optional:-->
<Fields>{"short_description":"test", "assignment_group":"Web Development Team", "urgency":"3",
"impact":"3", "description":"test description"}</Fields>
<!--Optional:-->
<Operation>Insert</Operation>
<!--Optional:-->
</tsk:insert>
</soapenv:Body>
</soapenv:Envelope>
Can you please tell me whether there is any obvious error.
Thanks,
Senraj A S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 02:16 PM
Can you have PowerShell execute a cURL command instead? If so you can use the ServiceNow REST API Explorer to generate sample working code that you can then leverage in PowerShell.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 02:22 PM
You can use powershell to create a REST request. Please check the links below
Powershell REST api examples - ServiceNow Express Support
json - Get ServiceNow Records Powershell - More than 250 - Stack Overflow
REST table API create a record - ServiceNow Express Support
ServiceNow API Example in PowerShell.md · GitHub
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 09:02 AM
Thanks for your answer.
I have used the REST end point. But I am getting some permission related error.
"ACL EXCEPTION INSERT FAILED DUE TO SSECURITY CONSTRAINTS"
I am using the following end point to create task using the Service Account.
Endpoint: https://domain.service-now.com/api/now/table/sc_task
But I can create an incident using the same service account
Endpoint: https://domain.service-now.com/api/now/table/incident
I have asked the concerned team for checking access permissions(to the sc_task table) for the Service account.
I just wants to know whether this issue is anything related with the script other than Permission issue
Thanks,
Senraj A S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 09:18 AM
Out of the box the user has to have the catalog_admin role to insert into the sc_task table. Incident requires the itil role. So yes there are some security differences in roles required. I don't know the full history why, but will say that catalog tasks are typically created by workflow automatically versus in a manual way.
I would suggest creating a new ACL for creating records in the sc_task table for your role. The catalog_admin will give you more permissions than necessary like the ability to updating the catalog items, etc.