Process Deployment via REST Interface

Hello,
I have been unsuccessfully attempting to use the REST interface to deploy a process to an instance of the Camunda process engine.

I am the standard http library, issuing the call from a Node JS server.

The current code returns the message {“type”:“RestException”,“message”:“multipart/form-data cannot be processed”}, but setting the content type to “application/json” does not help.

Has anyone had similar issues?

Kind regards,

Ciarán

Here is a generated example from Postman:

var fs = require("fs");
var request = require("request");

var options = { method: 'POST',
  url: 'http://localhost:8080/engine-rest/deployment/create',
  headers: 
   { 'Postman-Token': 'aa002511-9b7c-4ac2-88d6-5e3625db4278',
     'Cache-Control': 'no-cache',
     Accept: 'application/json',
     'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
  formData: 
   { 'deployment-name': 'script-test',
     'enable-duplicate-filtering': 'false',
     'deploy-changed-only': 'false',
     'scripttest.bpmn': 
      { value: 'fs.createReadStream("/path/to/file/scriptest.bpmn")',
        options: 
         { filename: '/path/to/file/scriptest.bpmn',
           contentType: null } },
     'script.js': 
      { value: 'fs.createReadStream("/path/to/file/script.js")',
        options: 
         { filename: '/path/to/file/script.js',
           contentType: null } } } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
1 Like

Thanks you very much Stephen!

I have got the example to work now - using the request library.

I think that the original problem was from the standard http library of Node JS. If I find out more on this matter, I will let you know.

Kind regards,

Ciarán

I am getting 415 not sure what is wrong here ! 
  public async createDeployment(deploymentName: string, path: string): Promise<any> {
    return this.checkFile(path).then((data) => {
      const url = `${camundaEngineUrl}/engine-rest/deployment/create`;
      const bodyFormData = new FormData();
      bodyFormData.append('deployment-name', deploymentName);
      bodyFormData.append('enable-duplicate-filtering', false);
      bodyFormData.append('deploy-changed-only', false);
      bodyFormData.append('deploymentName', {
        value: fs.createReadStream(path, 'utf8'),
        options: {
          filename: path,
          contentType: null,
        },
      });
      const options: AxiosRequestConfig = {
        headers: {
          'Cache-Control': 'no-cache',
          'Accept': 'application/json',
          'content-type': 'multipart/form-data',
        },
        data: bodyFormData,
      };
      if (camundaAuthorization) { options.headers.Authorization = camundaAuthorization; }
      return this.apiService.post(url, options);
    }).catch((err) => {
      return Promise.reject(err);
    });
  }

This topic has existed for a long time, but it’s been helpful, thanks for the replies.