Comments (6)
Hello!
Are you getting a 400 back? Do you have an example?
I'm pretty sure the SN REST API previously, when this library was first built, sent a 2xx response back upon those types of errors (bad request / malformed body), instead of a 400, and included the error in the OK-response.
Perhaps this behavior has changed in more recent versions of the SN API. The documentation still doesn't mention anything about 400 errors on POST requests, as far as I can see.
Anyway - I'll do some testing and look into this. Thanks for reporting :)
from pysnow.
Hey there. I was kind of stumbling in the dark without knowing the data policy for the payload, so I was getting quite a few of these errors in my initial attempts, before I got access to their API Explorer and realized there was more to the error than I originally thought.
To start with, I didn't know what was necessary in the payload to open an incident in ServiceNow. After some poking, I was just getting back the default errors from the API about unexpected response codes (403 in my case).
As an example, if I comment out some required values from my payload, with the updates I mentioned above I get some useful details back, rather than just the UnexpectedResponse message.
With the script as is, you can possibly reproduce the error by calling insert(table='incident',payload=payloadWithMissingRequiredData) and get a 403 back.
In my case, the following are required fields to open an incident:
category
description
caller_id
u_impacted_service
cmdb_ci
subcategory
impact
severity
contact_type
priority
location
assignment_group
short_description
urgency
u_affected_user
Here is the output when I include all of the required fields:
[me@somewhere ~]$ python openone.py
{'impact': 3, 'subcategory': 'Service Request', 'caller_id': u'33115a0d3d2d0600f4a09f32609319a2', 'u_impacted_service': u'1b66b8ed6f0a46007dce01dfde3ee4a0', 'cmdb_ci': u'1b66b8ed6f0a46007dce01dfde3ee4a0', 'description': 'A much longer description', 'category': 'Inquiry/Help', 'severity': 3, 'contact_type': 'Other', 'priority': 3, 'location': u'4e472b3f6f6102007dce01dfde3ee4cd', 'assignment_group': u'630c048e6ff94200cec3f941be3ee4c2', 'short_description': 'some request from someone with some team', 'urgency': 3, 'u_affected_user': u'33115a0d3d2d0600f4a09f32609319a2'}
INC0697332
And below is the output when I omit short description and affected user. Without the updates above all I get is the Expected: 201, got 403.
[me@somewhere ~]$ python openone.py
{'impact': 3, 'subcategory': 'Service Request', 'caller_id': u'33115a0d3d2d0600f4a09f32609319a2', 'u_impacted_service': u'1b66b8ed6f0a46007dce01dfde3ee4a0', 'cmdb_ci': u'1b66b8ed6f0a46007dce01dfde3ee4a0', 'description': 'A much longer description', 'category': 'Inquiry/Help', 'severity': 3, 'contact_type': 'Other', 'priority': 3, 'location': u'4e472b3f6f6102007dce01dfde3ee4cd', 'assignment_group': u'630c048e6ff94200cec3f941be3ee4c2'}
Traceback (most recent call last):
File "openone.py", line 53, in <module>
response = snobj.insert(table='incident',payload=ourpayload)
File "/usr/lib/python2.7/site-packages/pysnow.py", line 99, in insert
return r.insert(payload)
File "/usr/lib/python2.7/site-packages/pysnow.py", line 165, in insert
return self._get_content(response) # @TODO - update to return first key (API breakage)
File "/usr/lib/python2.7/site-packages/pysnow.py", line 260, in _get_content
content_json['error']['detail']))
pysnow.UnexpectedResponse: Unexpected HTTP response code. Expected: 201, got 403.
Error: Operation Failed
Details: Data Policy Exception: Short description is mandatory, Affected User is mandatory
from pysnow.
I've been away for awhile but now looking into this again.
And thanks for the really good input. I'll have this implemented asap.
from pysnow.
from pysnow.
Implemented in d113137 , which will be released in version 0.2.2.
message
and detail
will be accessible in the UnexpectedResponse
exception object using error_summary
and error_details
.
Also, documentation and examples coming up.
from pysnow.
Fixed.
from pysnow.
Related Issues (20)
- Why there isn't a context manager in the client? HOT 4
- Update a change request record using pysnow.response.Response update() fails. HOT 7
- Requests Hang with Network Blips HOT 4
- Pass certificate info while creating Oauth client HOT 2
- Returning display values when using get_multiple HOT 1
- Tag the source
- Passing a string like "2021-12-01 01:00:00: to less_than/greater_than
- Access servicenow's sys_report_template.do report download function HOT 1
- Unable to load the pysnow module HOT 2
- Upgrade pytz to a more recent version HOT 3
- Usage of sysparm_query_category
- Conversion to dataframe, options around "Display_Value"
- Problem in calling Service Now with custom API Name HOT 1
- ResourceWarning in attachment.upload. File not closed.
- Segmentation Fault upon import
- Unable to install pysnow because pytz version dependence HOT 4
- Resource.get() parameters persist for all requests
- Is this still active?
- pysbnow 0.7.16 on git but 0.7.17 on pip
- pysnow.oauth_client.OAuthClient.resource should allow to pass request parameters (e.g. timeout) the same way pysnow.client.Client.resource does
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysnow.