This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Trying to get data from service now to get all like wise server , can any one help me with query host_nameSTARTWITH that is having issues

class GetNonStructuredAction(BaseAction):
    def run(self, table, name, dev=False):

        default_payload = None
        try:
            self.get_client_with_default_payload(default_payload,dev)
        except Exception as err:
            return (False, err)

        names = [name]
        s = self.client
        for name in names:

            query = {"name": name}
            r = s.query(table=table, query=str(host_nameSTARTSWITH{{query}}))  # pylint: disable=no-member
            response = r.get_multiple()  # pylint: disable=no-member
            output = []
        for each_item in response:
            output.append(each_item)
        return output

Could you explain a bit more about what you’re doing here? Are you writing a new action for the Service Now pack?

What are issues that you have? Maybe explain a bit more about the command you’re running, the output that you’re getting, and how that differs from what you expect?

Im writing a new action in service now pack to get the list of servers that were having name that starts with similar words. so the service now query is u_active=true^nameSTARTSWITHservername

And what results are you getting? What is not working?

 File "/opt/stackstorm/virtualenvs/servicenow/lib/python2.7/site-packages/pysnow/request.py", line 88, in _all_inner
    yield self._get_content(response)
  File "/opt/stackstorm/virtualenvs/servicenow/lib/python2.7/site-packages/pysnow/request.py", line 316, in _get_content
    raise NoResults('Query yielded no results')
pysnow.exceptions.NoResults: Query yielded no results

What results do you expect to see? You haven’t said what your query was, and we have no idea what data you have in your ServiceNow system. So what results do you expect to get back?

What happens if you try using a simple Python script that uses the pysnow library to run your query? Does that work? What about just making manual curl calls against the API? Can you get it to return what you expect?

Break the problem down to the smallest parts, and look at those.