UiPath / orchestrator-nodejs

MIT License
8 stars 7 forks source link

Issue with postUploadPackage #6

Open SKlarsen84 opened 4 years ago

SKlarsen84 commented 4 years ago

I can't for the life of me figure out how to actually use postUploadPackage (or the api endpoint itself in any shape) via a nodeJS process.

I've tried variations such as:

`
let data = fs.createReadStream("HelloWorld.1.0.0.nupkg");

orchestrator.v2.odata.postUploadPackage(
      data,
      (err, response) => {
        if (err) {
          console.log(err);
        }
        console.log(response);
      }
    );`

as well as:

`
let data = fs.readFileSync("HelloWorld.1.0.0.nupkg");

orchestrator.v2.odata.postUploadPackage(
      data,
      (err, response) => {
        if (err) {
          console.log(err);
        }
        console.log(response);
      }
    );`
`

and even

    const form = new FormData();
    form.append("file", fs.readFileSync("HelloWorld.1.0.0.nupkg"));

    orchestrator.v2.odata.postUploadPackage(
       form,
      (err, response) => {
        if (err) {
          console.log(err);
        }
        console.log(response);
      }
    );`

but none of them work - I get the same error back from the api every time: message: 'The package file is required.', errorCode: 1677,

I've been banging my head against this for about 6 hours now and I just can't get it to work. Sorry for writing here but I'm utterly confused.

qbrandon commented 3 years ago

Hello, and sorry for taking so long to notice your report. You are correct, the library does not implement postUploadPackage properly as Orchestrator expects an incoming form-data payload while this library enforces JSON payloads for now (which is the relevant encoding for the vast majority of the available API) I will leave this issue open as it is definitely an improvement opportunity.