title: Angular http and spring boot rest service
body: <p>I am calling a spring boot REST service from my angular UI. It worked good as long as the Spring Boot Rest service was executed as a Spring boot App. But once i converted it to a WAR file and deployed on a Jboss 6.2.4 server, i am getting 404. I see that REST service call from the UI is successful but the request JSON is not getting passed. On the request JSON i am passing 2 strings and an uploaded excel file.</p>
  
  <p>This is my angular UI http call</p>
  
  <pre><code>App.service('getHeatMapDataService', ['$http', '$q', function ($http,      $q) {
  this.getHeatMapData = function (scope) {
      var url = 'http://localhost:8080/rest-services/fusiontables/upload';
      var deferred = $q.defer();
      $http({
              method: 'POST',
              url: url,
              headers: {
                  'Content-Type': undefined
              },
              data: {
                  stateCd: scope.stateCd,
                  addressExtras: scope.addressExtras,
                  uploadFile: scope.upFile
              },
              transformRequest: function (data, headersGetter) {
                  var formData = new FormData();
                  angular.forEach(data, function (value, key) {
                      formData.append(key, value);
                  });
  
                  var headers = headersGetter();
                  delete headers['Content-Type'];
                  return formData;
              }
          })
          .success(function (data) {
              deferred.resolve(data);
              console.log("Success");
              console.log(data);
          })
          .error(function (data, status) {
              deferred.reject(status);
              console.log("Failed");
          });
      return deferred.promise;
  }
  }]);
  </code></pre>
  
  <p>This is my Spring boot Rest controller when it was working</p>
  
  <pre><code>@RequestMapping(value="/upload", method=RequestMethod.POST)
  @ResponseBody
  public String getBoundaries(HeatMapUploadCommand uploadCommand) {
      logger.info("Heat Map Controller invoked " + uploadCommand);
      return null;
  }
  </code></pre>
  
  <p>This is my upload command</p>
  
  <pre><code>public class HeatMapUploadCommand {
  
  private String stateCd;
  private String addressExtras;
  private MultipartFile uploadFile;
  </code></pre>
  
  <p>After i deployed on Jboss, the request still hits the Spring Boot app but then it has all request params as null.</p>
  
  <p>This is the request payload</p>
  
  <pre><code>------WebKitFormBoundaryvCCnl3nhIgoW1MwR
  Content-Disposition: form-data; name="stateCd"
  
  CA
  ------WebKitFormBoundaryvCCnl3nhIgoW1MwR
  Content-Disposition: form-data; name="addressExtras"
  
  1234
  ------WebKitFormBoundaryvCCnl3nhIgoW1MwR
  Content-Disposition: form-data; name="uploadFile"; filename="CAdata.xlsx"
  Content-Type: application/vnd.openxmlformats-    officedocument.spreadsheetml.sheet
  
  
  ------WebKitFormBoundaryvCCnl3nhIgoW1MwR--
  </code></pre>
  
  <p>I tried changing the controller as </p>
  
  <pre><code>@RequestMapping(value="/upload", method=RequestMethod.POST)
  @ResponseBody
  public String getBoundaries(@RequestParam(value="stateCd") String stateCd,
          @RequestParam(value="addressExtras") String addressExtras,
          @RequestParam(value="uploadFile") MultipartFile file) {
      System.out.println("Heat Map Controller invoked " + stateCd);
      return null;
  }
  </code></pre>
  
  <p>Still no luck. This is the response i got.</p>
  
  <pre><code>{"timestamp":1464840821648,"status":400,"error":"Bad    Request","exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required String parameter 'stateCd' is not     present","path":"/rest-services/fusiontables/upload"}
  </code></pre>