0

I am trying to write a python script to post data to a Microsoft SQL server database that is connected to restful web service. However, I am getting an error which I do not understand and never came across before.

Python Code to post data:

import json
import requests
import pprint
url = 'http://192.168.1.111/api/Data'
data = {'ID': '1', "ChannelID': '34','TimeStampID': '45'}
data_json = json.dumps(data)
headers = {'Content-type': 'application/json'}
response = requests.post(url, data=data_json, headers=headers)
pprint.pprint(response.json())

The error I am getting below is this: enter image description here

I have also deleted any files with the name of json in order to prevent the wrong imports. What does the above error mean? I tried looking up what was kwargs from the following links but did not understand.

Understanding kwargs in Python

*args and **kwargs?

Would appreciate any assistance.

Athina
  • 55
  • 9
gram95
  • 103
  • 2
  • 15
  • The quotes in url are open. – Dhruv Aggarwal Aug 15 '17 at 04:15
  • Can you please check whether your service is up or not? Also, please check whether the request is reaching your server. The usage of args, kwargs here is correct. No need to worry about that. The api server seems to be the problem to me. – Dhruv Aggarwal Aug 15 '17 at 04:18
  • Made the corrections to the url. So, in this case, can I assume the following might be the cause of the problem: 1) URL problem 2)Service not up @DhruvAggarwal – gram95 Aug 15 '17 at 04:21
  • There is no problem with the url since it is a timeout and not a 404. Either the service is not up or the service is throwing a 504 somewhere inside itself. – Dhruv Aggarwal Aug 15 '17 at 05:04
  • What do the dist-packages/requests/api.py mean? @DhruvAggarwal – gram95 Aug 15 '17 at 06:53

1 Answers1

0

I am not sure about the error, but as for **args and **kwargs:

**args means you can add as many parameters as you need

**kwargs refers to the keywords in Python, the ones you cannot use as variable names. see:

>>> import keyword
>>> print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 
'del','elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 
'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 
'with', 'yield']
Athina
  • 55
  • 9