I am sending a POST request to my server which is throwing a 500 error when my server code attempts to read data from the POST request. But the data looks perfectly ok to me.
The POST data is:
<QueryDict: {u'{"firstname":"jack","lastname":"rowley","username":"jack","email":"info@mybiz.co.uk","password":"jack","city":"London","country":"UK","photo":"","genre1":"Comedy","genre2":"Horror","genre3":"Documentary","platform":"Cinema"}': [u'']}>
The Python code that is reading the POST data is:
username = request.POST['username']
password = request.POST['password']
email = request.POST['email']
It falls over at the first line, trying to access the username.
The AngularJS code that makes the POST request looks like this:
 url = apiDomain + '/profile/register/';
      var fn = 'jack';
      var ln = 'rowley';
      var un = 'jack';
      var pw = 'jack';
      var cf = 'jack';
      var em = 'info@mybiz.co.uk';
      var lc = 'London';
      var ct = 'UK';
      var ph = '';  //$('#photo_set').val();
      var genre1 = 'Comedy';
      var genre2 = 'Horror';
      var genre3 = 'Documentary';
      var platform = 'Cinema';
      return $http({
        method: 'POST',
        url: url,
        headers: {
          'Content-Type': "application/x-www-form-urlencoded"
        },
        data: {
          firstname: fn,
          lastname: ln,
          username: un,
          email: em,
          password: pw,
          city: lc,
          country: ct,
          photo: ph,
          genre1: genre1,
          genre2: genre2,
          genre3: genre3,
          platform: platform
        }
      }).then(function successCallback(response) {
        return response;
      }, function errorCallback(response) {
        return -1;
      }); 
     
    