Arcadier / Developer-Community-Support

:revolving_hearts: Share new ideas with us and report bugs/problems here
4 stars 1 forks source link

pre-Checkout - Generate Invoice API does not work properly #13

Closed renixnahc closed 4 years ago

renixnahc commented 5 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Use Node.js to create add an item to cart using API.
  2. Use Checkout - Generate Invoice and Orders from Cart and use cartItemID from Step 1 to generate an invoice.
var request = require("request");

var options = { 
  method: 'POST',
  url: 'https://inkit.sandbox.arcadier.io/api/v2/users/e6e67a9d-cc28-46cf-8f8e-d1abc5b76851/invoices/carts',
  headers: { 
     'Authorization': 'Bearer {token}',
     'Content-Type': 'application/json' 
  },
  body: { 
'5ffcd888-e2d0-4604-9dc5-d2a32d9c0227' 
  },
  json: true };

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

  console.log(body);
});

Expected behavior I expect to see something similar to what’s shown in the documentation, but instead I get an error 500. What am I doing wrong?

Screenshots

Desktop (please complete the following information): Running on MacOS Mojave, using Chrome

Arcadier commented 5 years ago

This is wrong:

body: { 
   '5ffcd888-e2d0-4604-9dc5-d2a32d9c0227' 
}

The body takes an array:

body: [ 
   '5ffcd888-e2d0-4604-9dc5-d2a32d9c0227' 
]
renixnahc commented 5 years ago

Oh okay that works, but it doesn’t really make sense for this one API to work like this. Usually JSON requests are in the form of:

 { 
   "id": [
      { 
        "id1": "...", 
        "id2": "..."
      }
   ]
}
Arcadier commented 5 years ago

That’s true, we will consider this as an improvement. Thanks for giving us this kinda feedback! :)