What's the current REST API to update (POST) asset files?

The playcanvas webpack plugin (https://github.com/whydoidoit/playcanvas-webpack-plugin) used to work for a while, but it appears like the editor API has changed and it no longer updates existing resources.

All the plugin does is make a POST call with the below details. Can anyone throw some light into any changes that may have affected this ?

let req = request({ uri:https://playcanvas.com/api/assets, method: 'POST', headers: { "Authorization":Bearer ${options.bearer}`

                    let form = req.form()
                    form.append("project", "" + options.project)
                    form.append("name", "" + filename.path)
                    form.append("asset", "" + filename.assetId)
                    form.append("data", JSON.stringify({order: filename.priority || 100, scripts: {}}))
                    form.append("preload", "true")
                    form.append("file", content, {
                        filename: filename.path,
                        contentType: "text/javascript"

Note that this API works in creating new asset files, but doesn’t use the assetId above to update existing resource.

OK, turns out that the API was fine and the problem was with the playcanvas editor.
It does some sort of client side caching which doesn’t show the real content of the file even if it’s updated from the REST API on the backend. Was able to figure it out when i actually downloaded the file instead of using the editor to inspect the content.

Glad to finally resolve this issue after 5 days of toil :frowning:

Having gone through this though, I think the playcanvas team should really consider exposing the API documentation for this. For any serious development we’re not going to be using the UI editor all the time. And when coding in your own editor like Webstorm or VisualCode with Es6/npm frameworks, it’s critical to have some way to upload the built files onto editor so we can test it seamlessly.

1 Like

Unfortunately, the API is not considered public and therefore can change at any time hence the lack of documentation.