0

I am trying to send data to a python script via POST but unable to read it. The UI is in AngularJS. I have seen similar questions but they are either not using AngularJS or not using POST.

The Angular code:

$scope.send = function(){

        $data = {
            "tableData":$scope.personsSelected
        }

        $postData = JSON.stringify($data);
        Services.post('testbed.cgi', $postData);
    }

Python Code:

formData = cgi.FieldStorage()
print json.dumps(formData)

Error Message:

TypeError: FieldStorage(None, None, []) is not JSON serializable

I have tried setting the content type to application/x-www-form-urlencoded but to no avail. What am I missing here?

nodoze
  • 127
  • 1
  • 14

1 Answers1

0

The issue is with the data you are trying to send as JSON. Whats the data you are trying to send? Is it a Python object? This may help you. Are those plain strings? Dictionary? Do they have invalid characters? You can use JSON Lint to check validity.

Community
  • 1
  • 1
avi
  • 9,292
  • 11
  • 47
  • 84