Create Invite api not sending emails

Hi,

I’ve been sending invites using the api (Discourse API Docs). When I send it on postman, I am getting the invite email. But when I implement it on laravel I’m not getting the email.

Here is the response when the api from laravel. I noticed that the emailed field is false.
image

Postman response the emailed field is true.

Any advice? Thanks.

someone else also reported this,

check this topic

yes this was a different error which was already resolved. the issue now is we’re not getting emails but using the api is successful.

i’m not sure if we need to enable anything? coz when i call the api on postman i get the email but on the laravel app we’ve created we’re not getting the emails.

Hey @yburhaniel,

It’s an old topic already, but I’m experiencing similar issue. API request to invite.json generates invite links, but does not send the email. Whereas if the same user to which the API key is bound to invites the users from UI, the email is sent normally.

How did you resolve this back then?

Did you set send_email?

I’m using python code like this:

invitation = {
          "email": u.mail,
          "group_ids": valid_group_ids(u.groups),
          "send_email": True,
}

site.invites.post(data=invitation)

Would you show us the code you are using?

Hi @thoka,

Thanks for you reply. Is it really that simple, that’d be great news!

For this one, I’m using Zapier, but with an object I created by following this API doc. Maybe that’s not the correct doc or I’m missing something else.

I have tried many different parameters there, but the latest is:

{
"email": "email@email.com",
"skip_email": false,
"custom_message": "Welcome to the forum",
}

I also just tried with the following. Unfortunately that did not cause invitation to be sent:

{
"email": "email@email.com",
"skip_email": false,
"send_email": true,
"custom_message": "Welcome to the forum",
}

But maybe the properties I have there are still somehow wrong.

I always do Reverse engineer the Discourse API to use the same parameters as the UI.

Good stuff, thanks for pointing that out to me. That’s an instinct that comes with longer Discourse experience, I guess. :slight_smile: Anyway, now that you said it, makes total sense.

Let me try and I’ll get back to here on how it went!

@thoka

Unfortunately still the same issue, status OK 200, but only the invite link generated.

The API from UI just had additional the explicit expires_at and max_redemptions_allowed properties set.

BTW, I’m using the system user via the integration, could that be a problem? That said, I think I also used an actual “human” user too, to test it with.

If you create invites via UI everything works as expected?

@thoka

Yeah, that’s the mystery, via UI it all works without issues.

Although, I noticed is that even if I send the invite from system user’s profile / invites section, it still shows in the invitation email that I’m (my user) the one who send the invite.

I would try with an administrative API key for your username.
Via API you should be able to get the same behavior as via UI.