title: ServiceNow REST API Integration: No JSON object could be decoded
body: <p>I tried do some integration towards serviceNow records using python script and referring example given in this link to update the records using Http Request Patch method: <a href="https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/reference/r_TableAPIPythonExamples.html" rel="nofollow noreferrer">Table API Python</a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>#Need to install requests package for python
  #sudo easy_install requests
  import requests
  
  # Set the request parameters
  url = 'https://instance.owndomain.com/api/now/table/sc_req_item/2a2851fe88709010b9120e9b506dd9a9'
  user = 'username'
  pwd = 'password'
  
  # Set proper headers
  headers = {"Content-Type":"application/json","Accept":"application/json"}
  
  # Do the HTTP request
  response = requests.patch(url, auth=(user, pwd), headers=headers ,data='{"u_switch_status_automation":"In Processing using Python", "u_switch_description":"The Automation currently processing this SR using Python"}')
  
  # Check for HTTP codes other than 200
  if response.status_code != 200: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()
  
   # Decode the JSON response into a dictionary and use the data
  print('Status:',response.status_code,'Headers:',response.headers,'Response:',response.json())
  </code></pre>
  
  <p>And the result I got is as follows:</p>
  
  <pre><code>/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'instance.owndomain.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
    InsecureRequestWarning,
  Traceback (most recent call last):
    File "/home/automation/switchConf/updateRecord.py", line 18, in &lt;module&gt;
      print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    File "/usr/lib/python2.7/site-packages/requests/models.py", line 898, 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")
  ValueError: No JSON object could be decoded
  </code></pre>