locaweb / python-servicenow

Python Library to interact and manage the ServiceNow database
Apache License 2.0
96 stars 47 forks source link

Default api (JSON) returns a web page instead of json. #23

Closed DanEhrlich closed 8 years ago

DanEhrlich commented 9 years ago

What do I need to do to get json back from a query instead of a html web page?

rbw commented 9 years ago

Sounds like you forgot to enable the API in ServiceNow.

DanEhrlich commented 8 years ago

Pretty sure it is enabled as the REST Explorer works.

rbw commented 8 years ago

Then I don't know, sorry.

You could try out python-servicenow-rest if you're using Eureka or later (it's for the SN REST API): https://github.com/rbw0/python-servicenow-rest

shaiguitar commented 8 years ago

Just saw this project. Got https://github.com/shaiguitar/snowclient.py#readme going earlier yesterday ( REST api access a-la /api/now/v1/table/ endpoints ). At this point has GET single resource and collection access, but the post/delete stuff should be pretty easy to add in.

Also has a query parser so date querying/OR'ing/ordering those service now quirks is a little easier to manage (QueryBuilder):

https://github.com/shaiguitar/snowclient.py/blob/master/tests/querybuilder_tests.py#L10

As well as walking embedded link tags within a result object the api returns back - https://github.com/shaiguitar/snowclient.py/blob/master/tests/client_tests.py#L62-L71

Feedback/Contributions appreciated.

ricardojfernandes commented 8 years ago

DanEhrlich, after Dublin version, of Service-Now, api works by default with JSONv2. http://wiki.servicenow.com/index.php?title=JSONv2_Web_Service#gsc.tab=0

If you want to enable JSON you need activate the plugin: http://wiki.servicenow.com/index.php?title=Legacy:JSON_Web_Service#gsc.tab=0