API POST for New User

I’m stuck and don’t know if this is merely my own error, if I’m receiving a false positive, or something else.

When I do a POST request via Postman, I get a SUCCESS message:
https://site.co/users.json?Api-Key=12345abcde12345&Api-Username=system&email=name@email.co&group_names=Alumni&custom_message=Welcome321

Message:

{
    "success": true,
    "active": false,
    "message": "<p>You’re almost done! We sent an activation mail to <b>name@email.co</b>. Please follow the instructions in the mail to activate your account.</p><p>If it doesn’t arrive, check your spam folder.</p>"
}

However, when I check my inbox, I have no notification. Nothing in my /logs, no user.

In an attempt to troubleshoot, I do a simple GET request:

https://site.co/admin/email.json?Api-Key=12345abcde12345&Api-Username=system

I get no success reply. The reply is <!DOCTYPE html> ...

So I manually go to https://site.co/admin/email.json and see:
{"delivery_method":"smtp","settings":[{"name":"address","value":"smtp.sendgrid.net"},{"name":"port","value":2525},{"name":"user_name","value":"apikey"},{"name":"authentication","value":"plain"},{"name":"enable_starttls_auto","value":true}]}

Any ideas what I can try? My outcome is being able to invite a new user, added to a Group, via Webhook/POST.

You’ll need to move the API key into the header.

A long time ago I solved what I think is your problem by creating, deactivating, and activating the user.

1 Like

Your script is Javascript (jQuery). Using type="application/json" is generally for JSON in the script not Javascript. Here is an example:

<script id="data" type="application/json">
{"org": 10, "items":["one","two"]}
</script>

My understanding is your script tags should look like this:

<script>
$.ajax({
method: "POST",
url: "https://site.co/invites",
headers: { "Api-Username": "system", "Api-Key": "12345" },
data: { 
"email": "grow@site.co",
"group_names": "Alumni",
"custom_message": "Welcome123"
}
});
</script>

For Javascript, you don’t need to specify type="javascript" anymore, as this was made obsolete a while back.