playcanvas / playcanvas/editor
Some REST API endpoints cannot be accessed via the Launch Tab
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 215
- Avg merge
- 1d 29m
- Merged PRs (30d)
- 30
Description
Related ticket: https://forum.playcanvas.com/t/get-asset-file-from-the-rest-api/24259
Use cases included making level editors that run in the launch tab and write back to the assets in the Editor. In the case below, this can be worked around by using the private end point of https://launch.playcanvas.com instead of http://playcanvas.com prefix.
Hello everyone,
I'll get straight to the point, I'm trying to get an asset file from a private Playcanvas project I have access to. For this purpose I'm trying to use the REST API, specifically the route documented here REST API GET ASSET FILE , using the following code:
//Headers definition: Authorization token is needed to use the Playcanvas API myHeaders = new Headers({ "Authorization": `Bearer ${Constants.API_TOKEN}` }); //Playcanvas REST API: GET ASSET FILE let myReq = new Request(`https://playcanvas.com/api/assets/${modelAsset.id}/file?branchId=${Constants.BRANCH_ID}`); await fetch(myReq, { headers: myHeaders , method: 'GET' }).then(function(response){});But the response to this is an asset not found 404 error, which is weird cause if I use the route to get the asset details like this:
let myReq = new Request(`https://playcanvas.com/api/assets/${modelAsset.id}?branchId=${Constants.BRANCH_ID}`);This returns the assets details correctly with a 200 code. I have also tried to use a route like this, from another forum post:
let myReq = new Request(`https://playcanvas.com/api/assets/${modelAsset.id}/file/${modelAsset.name}?branchId=${Constants.BRANCH_ID}`);This previously worked, but now throws a CORS error.
Can this be related to the project being private?
I would appreciate any help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the REST API asset-file request from the Launch Tab, comparing it with the asset-details request and the launch.playcanvas.com workaround described in the issue. Check the linked REST API documentation and forum ticket. Done means the affected endpoints can be accessed from the Launch Tab for authorized private projects without the reported 404 or CORS failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100