Is there any documentation available explaining how to upload files via Indicium (rel. 2021.1.10).
In Fidler I see that a different mechanism is now used, which uses the content-Type: application / octet-stream.
How can I get that done from an external application?
Page 1 / 1
Hello Harm,
There have been no changes to how file uploading works in Indicium Universal for over a year.
When it comes to adding/editing records and executing tasks/reports, Indicium Universal offers two APIs. What you see when using the Universal GUI is what we call resource staging. Clicking add/edit record or a task/report will perform a request that creates a resource in Indicium. Every field the user enters will be a request that changes the state of this resource. And finally, saving the record or executing the task/report is another request, which will cause the action to be performed. This way, the state of a record/task/report is managed by Indicium and Indicium will also take care of all application logic. Since through this method, every change to a field is its own request, we can upload files much more efficiently. Rather than sending the entire contents of the file in the JSON body of the request, we can now stream it to the server, using the standard way to do this in HTTP.
The other API is similar to Indicium Basic, where a single request encapsulates the entire action and multiple values are passed to Indicium simultaneously. We want to offer this method as well, because it makes using Indicium’s API from an external application a lot easier. Please read the following blog post to understand how both methods work https://community.thinkwisesoftware.com/blogs-21/resource-staging-1070.
You will probably want to use the second method, since you’re calling the Indicium API yourself. If the files that you are uploading a reasonably small (a few MBs), I would recommend using this method. The file can then simply be added to the JSON body as shown below. Please do read the blog I linked to understand which fields you need to add in the body, which should be omitted and in which order they should be in the body.
If your files are much larger, then the other method is recommended. Since this API is a bit more complicated, I’ll await your answer first.
I am familiar with the existing API, but I am interested in the new variant. I saw that the current version of the Universal GUI uses that and I think it works much better when uploading multiple large files (>5Mb).
This first request determines the file name at the destination and in the record on the database. Note that it could have a suffix added to it to make it unique.
POST /iam/appl/staged_project_document(b03b9235-dcde-43cb-82b6-a66752d132fb)/upload_document
Content-Type: x Content-Length: x
-- binary data
This second request streams the file data to Indicium. Note that there is no specifc Content-Type that you need to use. It could be the generic application/octet-stream, but it might as well be image/png, you can even omit the Content-Type header altogether. It's simply an HTTP binary file transfer request that will stream a file to a server in chunks. Any full fledged HTTP client will be able to do this for you. It's a bit hard to explain without knowing what type of client you're using. It comes down to setting the Content-Length header on the request and then streaming that number of bytes through the connection.
Here is an example in Insomnia:
The request it creates looks like this and it returns a 204 success result.
I hope this helps.
Hi Vincent,
OK, I think this is clear, I will investigate further.