Skip to content

Instantly share code, notes, and snippets.

@fdstevex
Created May 30, 2014 19:37
Show Gist options
  • Save fdstevex/285ca51c5ae487fb2e6b to your computer and use it in GitHub Desktop.
Save fdstevex/285ca51c5ae487fb2e6b to your computer and use it in GitHub Desktop.
AngularJS: Submitting JSON using a MIME POST
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