Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

415 on get invitation-link #74

Open
benoit03 opened this issue Oct 13, 2020 · 2 comments
Open

415 on get invitation-link #74

benoit03 opened this issue Oct 13, 2020 · 2 comments

Comments

@benoit03
Copy link

Hello,
i receive a 415 when i try to generate an invitation-link with your module.

i have an access token, my businessID, everything work fine to get all review :
await client("/v1/private/business-units/${process.env.TRUSTPILOT_BUSINESS_ID}/reviews")

but when i try to generate an invitation-link, i have a 415, it's a problem of media type. Maybe the content type : apllication/json is not set. But i don't know how to set it with your module.

This is my request :

await client.post("/v1/private/business-units/${process.env.TRUSTPILOT_BUSINESS_ID}/invitation-links", { name: user.name, locale: "fr-FR", redirectUri: "https://stootie.com", email: user.email, });

everything work fine on POSTMAN.

@addict67
Copy link

addict67 commented Jul 2, 2021

It's a bit of a late answer but if it can help other people, it's fine I guess.

node-trustpilot uses Request (which is deprecated btw) so if you want to use queryStrings or change the Content-Type header, you can use the qs and headers properties, like this:

await client.post(
    '/v1/private/business-units/${process.env.TRUSTPILOT_BUSINESS_ID}/invitation-links',
    {
        qs: {
            name: user.name,
            locale: 'fr-FR',
            redirectUri: 'https://stootie.com',
            email: user.email
        },
        headers: {
            'Content-Type': 'application/json'
        }
    }
);

More informations on those options in Request's core repository

@AmericasEngineer
Copy link

It's a bit of a late answer but if it can help other people, it's fine I guess.

node-trustpilot uses Request (which is deprecated btw) so if you want to use queryStrings or change the Content-Type header, you can use the qs and headers properties, like this:

await client.post(
    '/v1/private/business-units/${process.env.TRUSTPILOT_BUSINESS_ID}/invitation-links',
    {
        qs: {
            name: user.name,
            locale: 'fr-FR',
            redirectUri: 'https://stootie.com',
            email: user.email
        },
        headers: {
            'Content-Type': 'application/json'
        }
    }
);

More informations on those options in Request's core repository

Somehow qs: gave an empty body error.(A non-empty request body is required.) Instead, I used body:

await client.post(
  `/v1/private/business-units/${process.env.BUSINESS_UNIT_ID}/invitation-links`,
  {
    body: {
      name: user.name,
      locale: "en-US",
      redirectUri: `${process.env.REDIRECT_URI}`,
      email: user.email,
    },
    headers: {
      "Content-Type": "application/json",
    },
  }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants