Remix using POST

Hello,

I’d like to remix an app using env vars with the POST method described here: How do I configure a Remix so my users can get started in one click? - Glitch Support

I’ve tried the following JS snippet to perform the post request:

fetch('https://api.glitch.com/project/achieved-creative-paneer/remix', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({env: { PORT:3000, KEY:132456}})
  });

But I have a 404 with the following body:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /projects/achieved-creative-paneer/remix</pre>
</body>
</html>

the project does exist: Glitch :・゚✧

Do I do something wrong or is this feature broken?

Thanks

Hi sebsheep,

It’s not a feature I’ve used, but just to check something: your first code sample says /project/ and your return value says /projects/ (with an ‘s’). Did you try both or does the error not match the request?

Cheers!

1 Like

Hi SteGriff,

Thanks for replying. Yes I tested with both project and projects and both fail with this Cannot POST /project(s)/.../remix thing.

(accordingly to the docs, the projects should work)

I think you may have forgotten a /v1/:slight_smile:

$ curl -X POST https://api.glitch.com/v1/projects/achieved-creative-paneer/remix
{"message":"project id is not a valid uuid","code":"VALIDATION_ERROR"}

You may also need to get the ID of the project instead of the name.

oh cool, I hadn’t known that this was documented. and that that documentation is out of date.

it does indeed seem that this api has moved on to a /v1 version. you can remix by project name. I have some sample code here snail-cli/index.js at v2.3.0 · wh0/snail-cli · GitHub

key consideration here if you’re really doing this programmatically: you need to be authenticated, with an authorization header that contains a user’s persistent token. if the user is registered, then you’ll be fine. but if it’s an anonymous user, it’ll need some additional field in the request body with a recaptcha challenge.