I am trying to pass data in json format from a python script in Raspberry Pi 2 to a web service. I have tried the following code:
import json
import requests
import pprint
url = 'http://192.168.1.101/TestWebsite/api/SecondlyReadingDatas'
data = {'ID': '1', "ChannelID': '34','TimeStampID': '45}
data_json=json.dumps(data)
headers = {'Content-type': 'applcation/json'}
response = requests.post(url, json=data)
pprint.pprint(response.json))
However, I am getting the following error:
{u'Message':u'An error has occured'}
I have also tried changing the response = requests.post(url, json=data)
toresponse = requests.post(url, data=data_json, headers=headers)
I referenced my python code from the following link:
REST post using Python-Request
I am however, still getting the same error message. I have no idea how to debug it since it does not display what kind of error. Would appreciate any help