StackStorm-Exchange / stackstorm-servicenow

ServiceNow Integration Pack
https://exchange.stackstorm.org/
Apache License 2.0
11 stars 21 forks source link

Passing certain custom parameters doesnt seem to make a difference #8

Open alex-r-girard opened 6 years ago

alex-r-girard commented 6 years ago

For example,

Passing {"sysparm_limit":"1"} as the query when getting records from the incident table still returns all the records.

Passing {"state":"2","sysparm_fields":"sys_id,number,caller_id,opened_at,short_description,cmdb_ci"} as the query when getting records from the incident table will correctly filter down the returned results to only records that have state=2. However, all records fields are returned (not just the ones requested in the sysparm_fields parameter)

LindsayHill commented 6 years ago

There's not much going on within ST2 for this - it looks like it just passes the query through to pysnow. Do you think the problem is in the ServiceNow API itself, or in pysnow's handling of query?

What happens if you try directly querying the ServiceNow API?

alex-r-girard commented 6 years ago

Its definitely with the pysnow handling of the query. I have absolutely no issues when directly querying the ServiceNow API (either using the requests module in python or using cURL)

LindsayHill commented 6 years ago

This pack pins pysnow to 0.6.5. Might be worth checking with upstream pysnow project, to see if this is resolved in a later version, or if an issue needs to be logged against that library? https://github.com/rbw0/pysnow

alex-r-girard commented 6 years ago

I tested this with pysnow directly from my computer and did not encounter any issues. As a last check, I modified the get.py script to have display_value = True and exclude_reference_link = True which worked perfectly when testing locally with pysnow but did not modify the response results when using the ServiceNow pack.

from lib.actions import BaseAction

class GetAction(BaseAction):
    def run(self, table, query):
        s = self.client
        s.parameters.display_value = True
    s.parameters.exclude_reference_link  = True
        r = s.query(table=table, query=query)  # pylint: disable=no-member
        response = r.get_all()  # pylint: disable=no-member
        output = []
        for each_item in response:
            output.append(each_item)
        return output

So it looks like whatever I pass to the client (besides certain values in the query and the table name) gets excluded at execution.

LindsayHill commented 6 years ago

When you were testing with pysnow, which version were you using? The same version pinned in this pack? Or a newer version?

alex-r-girard commented 6 years ago

Good catch! Im using 0.7.3 locally which is different that what the pack uses

LindsayHill commented 6 years ago

I think it might be worth trying a newer version of pysnow in your ST2 Servicenow pack virtual environment, and see if (A) that works as expected, and (B) doesn't break anything else.

Should be easy enough to update with something like /opt/stackstorm/virtualenvs/servicenow/bin/pip install -U servicenow

If that does work, and everything else looks good, then it's easy to update this pack.

alex-r-girard commented 6 years ago

FYI I reinstalled pysnow locally to match the same version as the one used by the pack and my code still works fine locally so it doesnt look like this issue is due to a version difference.

namachieli commented 6 years ago

I am also running into this issue. Its not a big deal since its just extra data, but it would be helpful to be able to specify only the fields needed to be returned.