Update asset with REST API

Hello everyone,

I’m testing the REST API on a public project and I have run into some issues when trying to PUT an existing asset. Following the documentation Assets - Update asset in the User Manual and the example given in this forum post, I have created this request code:

    //Headers definition: Authorization token is needed to use the Playcanvas API
    let myHeaders = new Headers({
        "Authorization": `Bearer ${this.apiToken}`

    var data_to_save = { "testValue" : "nothing" };

    let jsonBlob = new Blob([JSON.stringify(data_to_save)], { type: 'application/json' });

    //Write data on JSON Back Up
    let formData = new FormData();
    formData.append("branchId", this.branchID);
    formData.append("file", jsonBlob, {
        filename: "SecurityBackup.json",
        contentType: "application/json"

    let myReq = new Request(`https://playcanvas.com/api/assets/${this.jsonDataID}`);

    await fetch(myReq, { 
        headers: myHeaders,
        method: 'PUT',
        body: formData

But it throws a forbidden 403 error despite being a public project, I guess it has to do with the format of the request.

I would appreciate any help.

Where are you running this request from? Local node process?

From the launch tab of a public Playcanvas project, just testing in this case.

It’s likely to be the same issue as your other post. I think this specific endpoint has a DENY from the launch tab. I’ve had a similar question from another user and the code works fine in the Editor tab, just not the launch tab.

We have a ticket to evaluate the REST API access from the launch tab

The workaround the user did was to copy the content to the clipboard and open a Code Editor tab for the file so that the user can paste the updated content in. Not ideal but ‘works’