Getting a 400 Bad Request error with setEmailGuestlist POST API

Hello, I’m getting a 400 bad request error in PostMan when I try to test this API for my space. I’ve tried changing around the payload in the body that I’m sending, but I get the same response. Can someone take a look at the below screenshots to see if I might be missing something, or have something wrong? Thanks for any advice you can give.


sorry for the delay – my first guess would be the spaceId, I’m confused about why it doesn’t have quotes around it. also you probably need \\ instead of just one \

Hi, thanks for responding! I originally had \, but it wasn’t working. I had the same for the getEmailGuestList, but it wasn’t working for that API either. I then changed the spaceID to use \ for the getEmailGuestList API, and it worked. Inregards to the quotes, I’ve tried several combinations of using surrounding quotes/not using quotes around the key value pairs, but I get the same result. The documentation doesn’t really specify either way, and the example doesn’t use quotes.

Example:
axios.post(“https://api.gather.town/api/setEmailGuestlist”, {
apiKey: API_KEY,
spaceId: SPACE_ID,
guestlist: guestList,
overwrite: true,
})

Would you be able to give me an example of the body that would work for this API? For example, what would need to change in the below body?

const axios = require(‘axios’);

axios.post(“https://api.gather.town/api/setEmailGuestlist”, {
apiKey: esf97yr293hr98 (this is just gibberish),
spaceId: 3uYbZwP7GGspBgQ5\MixxiverseArcade,
guestlist: {“setEmailTEST@email.com”:{“name”:“”,“affiliation”:“Mixxi”,“role”:“”}},
overwrite: false,
})

this should work (with valid api key)

const axios = require("axios");

axios.post("https://api.gather.town/api/setEmailGuestlist", {
  apiKey: "esf97yr293hr98", // (this is just gibberish)
  spaceId: "3uYbZwP7GGspBgQ5\\MixxiverseArcade",
  guestlist: {"setEmailTEST@email.com":{"name":"","affiliation":"Mixxi","role":""}},
  overwrite: false,
});

(indent doesn’t matter, just for readability)
also some of your "s were a weird nonstandard character… I’m not sure if that was the forum being fancy or what

I got the same error unfortunately. I also copied the body into Notepad and then copied and pasted from there, just in case any other weird characters were in it, but no luck. Using my apiKey, I called the getEmailGuestlist API, and that worked just fine…

Few things: The body for the Postman call should be a JSON blob, not an axios call. The axios call is what postman is trying to do for you (probably using fetch though).

If you instead set the body to:

{
"apiKey": "YOUR_KEY_HERE",
"spaceId": "YourSpace\\IDandNameHere",
"guestlist": {
  "email@email.email": {
      "name": "example",
      "affiliation": "test",
      "role": ""
   }
},
"overwrite": true
}

That should be accepted as properly JSON encoded like the endpoint wants. The code in the docs is meant for implementation in a JS/TS program, not in a tester/helper program like Postman.

There may be other factors at work here, but this is the big one I assume is causing issues.

2 Likes

Sorry for the late reply. This worked! Thanks for your help, and I was also able to trigger the POST request successfully using Fetch on my site.