Skip to content

Update a change request record using pysnow.response.Response update() fails.  #166

@ksanand

Description

@ksanand

I am trying to update the description of a standard change request like shown below but getting error

api_path = /sn_chg_rest/change/standard/7fb6375cdb4624106377cae43a961924
 base_path = /api
 client = pysnow.Client(instance=instance, user=os.environ["USERNAME"], password=os.environ["PASSWORD"])
 resource = client.resource(base_path=base_path,api_path=api_path)
 result = resource.get()
 print(result.__dict__)
 ####{'_stream': False, '_chunk_size': 8192, '_count': 0, '_response': <Response [200]>, '_resource': <Resource [/sn_chg_rest/change/standard/7fb6375cdb4624106377cae43a961924/api] at 0x7f41460f5350>}
 result.update({"description": "blah"})  

File "/apps/home/u208825/.local/lib/python2.7/site-packages/pysnow/response.py", line 262, in update
return self._resource.update({"sys_id": self["sys_id"]}, payload)
File "/apps/home/u208825/.local/lib/python2.7/site-packages/pysnow/response.py", line 48, in getitem
return self.one().get(key)
File "/apps/home/u208825/.local/lib/python2.7/site-packages/pysnow/response.py", line 231, in one
result, count = self._get_buffered_response()
File "/apps/home/u208825/.local/lib/python2.7/site-packages/pysnow/response.py", line 159, in _get_buffered_response
result = self._response.json().get("result", None)
File "/apps/home/u208825/.local/lib/python2.7/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")

When I ran pdb, the failure happens in the following line

return self._resource.update({"sys_id": self["sys_id"]}, payload)

The above returned the error. There is no sys_id. How can resolve this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions