Getting HTTP POST Error : {"reason":null,"error":"Request JSON object for insert cannot be null."}
<p>I am getting HTTP POST error when I am trying to connect to a Service Now Instance for Change Request Automation using Python. Here is the script I am using with Python 3.4.4</p>

<pre><code># SNOW CR AUTOMATION SCRIPT
import requests

import json

# put the ip address or dns of your SNOW API in this url
url = 'http://&lt;&gt;/change_request.do?JSONv2&amp;sysparm_action=insert'


data= {
    'short_description': '&lt;value&gt;',
    'priority': '&lt;value&gt;',
    'reason': '&lt;value&gt;',
    'u_reason_for_change': '&lt;value&gt;',
    'u_business_driver': '&lt;value&gt;',
    'u_plan_of_record_id': '&lt;value&gt;'
      }

print ("Data Inserted :")
print (data)

#Content type must be included in the header
header = {"Authorization":"Basic V1NfRVRPX1ROOkBiY2RlNTQzMjE=","Content-   Type":"application/json"}

#Performs a POST on the specified url.
response = requests.request('POST', url, auth=("&lt;value&gt;","&lt;value&gt;"), json=data, headers=header)

print ( " Header is :  ")
print (response.headers)
print ("                                                                ")
print ( "HTTP Response is :" )
print (response)
print ("                                                                ")
print ("***********************")
print (" Output : ")
print ( response.text)
</code></pre>

<p>I am getting an error as below while running the above script.</p>

<pre><code>Output : 
{"reason":null,"error":"Request JSON object for insert cannot be null."}
</code></pre>

<p>I am not sure why this error is thrown. Can anybody please help on this ?</p>

<p>This is a working example I tested on my instance. I am using REST Table API to insert a change request. It's not true that it can not be http. It's whatever protocol your instance allows to connect, say from browser. </p>

<pre><code>#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = '&lt;yourinstance base url&gt;/api/now/table/change_request'
user = &lt;username&gt;
pwd = &lt;password&gt;

# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}

# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers ,data="{\"short_description\":\"test in python\"}")

# Check for HTTP codes other than 201
if response.status_code != 201: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
</code></pre>

python rest post servicenow