Hey everyone, can anyone give me some tips on how to use the subscription API v3? I made a request to this endpoint, but it returns “Invalid account name”:
fetch(“/api/rns/pub/subscriptions”, {
method: “GET”,
headers: {
“Content-Type”: “application/json”,
Accept: “application/json”
}}).then((response) => response.json())
.then((response) => console.log(response));

Documentation:
List subscriptions (vtex.com)
One detail is that making this request on the site before the migration to IO works, which would be the link “{accountname}.vtexcommercestable.com.br”. Could it be that it doesn’t work for IO?
Hi Willian! Good morning, how’s everything going?
So… The problem is the account name you’re using, just as the error says. I’d recommend that you double-check the account name you’re using and make sure there are no special characters, spaces, or any typos in that field.
Karina Mota
Field Software Engineer | VTEX
Hi Karina, first of all thank you for your response.
But in this case, I’m using a relative URL for the request, so it would be the site itself + the endpoint: "cliente.com.br/api/rns/pub/subscriptions"
I’m not sure if that would cause any issue.
As I mentioned, if I use the URL "cliente.vtexcommercestable.com.br/api/rns/pub/subscriptions", which would be the request against the old URL, it works.
Do you have any other suggestions as to what might be happening?
Hey @willian.sato, how’s it going?
I believe that in this context you’ll need to create a middleware to make this request using the absolute URL, since VTEX requires the accountName at the beginning of the route, as in the example:
{accountname}.vtexcommercestable.com.br/api/rns/pub/subscriptions
In fact, if you run a test using any API client like Postman, you’ll get a 400 status error with “Invalid AccountName” in the body if you send a request without the accountname at the beginning of the route, as in your example:
{storedomain}.com.br/api/rns/pub/subscriptions
Cheers!
Hi @willian.sato, I agree with what @andremiani mentioned above — you need to use the route in exactly the following format:
https://{{accountname}}.vtexcommercestable.com.br/api/rns/pub/subscriptions
In other words, using a middleware might be the most suitable solution for your case.
Karina Mota
Field Software Engineer | VTEX