Never mind, I see what you’re saying. The API seems to be ignoring the ID in the URL for the /status request and creates a new (blank) stock transfer with status = COMPLETED and no stock transfer items instead. That’s bizarre.
So my hunch is that the API uses the ID from the payload instead of the one from the URL (request parameters) to locate the stock transfer. You probably still need to include the ID in the URL, but you may also need to pass the ID in the payload.
POST https://openboxes.ngrok.io/openboxes/api/stockTransfers/ff80818186de43cc0186de45904f0001
{
"id": "ff80818186de43cc0186de45904f0001",
"status": "COMPLETED"
}
But something doesn’t seem right, so I’m going to batman-signal the developer who wrote that API to see if he has any thoughts.
@Artur does this seem right? Can you see something else going on the Stock Transfer API that might explain this behavior?
So as for the answer to your question from the other day
So right now there is no way to use openboxes for what I need?
To be completely honest, it seems like a bad time to consume our APIs. I didn’t realize they were this unusable from the outside. There are other major issues as well namely, the lack of a coherent authentication and authorization mechanism i.e. we currently rely on cookie-based authentication and we allow API users to manhandle any location they want.
And while I’m planning to prioritize the API over the next few weeks, I can’t say I would recommend using them until we fix all of these bugs as well as whatever else we uncover.
1 Like
POST https://openboxes.ngrok.io/openboxes/api/stockTransfers/ff80818186de43cc0186de45904f0001
{
“id”: “ff80818186de43cc0186de45904f0001”,
“status”: “COMPLETED”
}
This payload has correctly updated the status of this transfer, but… now its stockTransferItems is an empty array and it doesn’t have items in UI
It looks like I need to pass all the data from the previous step in payload.
So weird. I’m investigating that, but in the meantime here’s a video to show you what I did the other night to figure out what data I needed to pass to the Stock Transfer API Screencastify
Disregard. Rollback appears to only be available for return orders.
One other trick you might not have encountered …
If you are looking to use the same Stock Transfer over and over while testing you can POST to the rollback
subresource to rollback the state from COMPLETED.
POST https://openboxes.ngrok.io/openboxes/api/stockTransfers/:id/rollback
That will allow you to reuse the same stock transfer while testing.
So I’ve made some progress on this but probably not enough to make this production ready before I leave for vacation this weekend.
Progress / work-to-be-done
a) I’ve added a new transaction API that will handle CRUD for transactions using a single request.
b) I’ve also added basic auth so we don’t have to authenticate before sending API requests. The reason we haven’t implemented basic auth or API keys / tokens is that our app is our only API client at the moment so it was unnecessary. I was hoping to wait until we migrated to the latest version of Grails (i.e. Spring Security), but I think it should be fine to add a temporary solution for now.
c) The last part will be adding authorization so that we require the API user to have write access to the location for which they are creating transactions.
If you’re still interested, I could potentially push my feature branch to github if you have means to build and deploy the code. I could also supply you with a WAR file or deploy the branch to one of my test servers if you want to test it out.
If not, I’ll continue the work when I get back in April.
Justin
We went with our own implementation that should meet our needs for now, so take your time and enjoy your vacation