rbw/pysnow

snow updated fail

Closed this issue · 4 comments

I get an error when I try to use update

File "/home/rochana/service_now/app/.env/lib/python3.6/site-packages/pysnow/request.py", line 115, in update
"/{0}".format(record["sys_id"])
File "/home/rochana/service_now/app/.env/lib/python3.6/site-packages/pysnow/url_builder.py", line 59, in get_appended_custom
self.validate_path(path_component)
File "/home/rochana/service_now/app/.env/lib/python3.6/site-packages/pysnow/url_builder.py", line 33, in validate_path
% path
pysnow.exceptions.InvalidUsage: Path validation failed - Expected: '/[/component], got: /{'display_value': '42afe2a71b92009445f5fc49cd4bcbd7', 'value': '42afe2a71b92009445f5fc49cd4bcbd7'}

i went ahead and changed

self._url = self._url_builder.get_appended_custom(
            "/{0}".format(record["sys_id"])
        )

to

self._url = self._url_builder.get_appended_custom(
            "/{0}".format(record["sys_id"]['value'])
        )

In request.py and it works fine now.
I'm not sure if it is a real issue or just specific to our ServiceNow.

rbw commented

Thanks for reporting this. Looks like a bug with update operations when sysparm_display_value is set to all.

Can you see if it works better with display_value set to False?

...
incident = c.resource(api_path='<path>')
incident.parameters.display_value = False
incident.update(...)

yes I have to set
incidentResource.parameters.display_value = "all"
to get some extra data.
but yes, your suggested solution work.
I guess i'll have to create another resource with
parameters.display_value = False
to do updates?

rbw commented

Sure, you could do that as a temporary workaround, until the bug has been fixed.

rbw commented

Should be fixed with #147 - can you verify?

Thanks