Created
May 30, 2014 19:37
-
-
Save fdstevex/285ca51c5ae487fb2e6b to your computer and use it in GitHub Desktop.
AngularJS: Submitting JSON using a MIME POST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return $http({ | |
method: "POST", | |
url: "/2/projects?accessToken=" + $userService.accessToken, | |
// The undefined Content-Type is intentional; with that, the browser will genearate | |
// the MIME boundaries and set the content type later. | |
headers: {'Content-Type': undefined }, | |
transformRequest: function (data) { | |
var formData = new FormData(); | |
formData.append("project", angular.toJson(postVars)); | |
return formData; | |
}, | |
}).then(function (response) { | |
console.log("ServiceClient added project: %o", response); | |
return response; | |
}, function (reason) { | |
console.log("ServiceClient failed adding project: %o", reason); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment