# Post-registration action with Salesforce not working for "live" calls

**URL:** <https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111>\
**Category:** Get Help\
**Tags:** actions-integrations, registration, salesforce, actions, post-user-registrati\
**Created:** [December 17, 2021, 1:39pm UTC](https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111 "2021-12-17T13:39:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WellBloud](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wellbloud/32/33865_2.png) [@WellBloud](https://community.auth0.com/u/WellBloud)\
**Post date:** [December 17, 2021, 1:39pm UTC](https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111/1 "2021-12-17T13:39:07Z")

</div>

This is very frustrating. I’m trying to do a POST request to Salesforce whenever user registers via email.

I created an Action for this, put it into the post-registration flow but it’s simply not working. There are 3 other Actions and those are working just fine.

If I try to hit the Salesforce endpoint with Postman it works. If I open the Action and try to test it, it also works - I can see new Salesforce item added and even `console.log` show I got `200` response.  
However if I try to use this either from Auth0 _Getting started_ page → _try it out_ (or if I use my application which is using Auth0) the action will simply fail to create new records in Salesforce.

How can this be possible? If you run Test in the Action it works, but when trying live call it doesn’t? Even more frustrating is that you have no way of knowing what’s wrong, since there are no logs for the actions.

I have `axios@0.24.0` in the Modules and also the secret is there and it’s correct URL. Below is the code:

```auto
const { URL } = require("node:url");
const axios = require("axios");

/**
* Handler that will be called during the execution of a PostUserRegistration flow.
*
* @param {Event} event - Details about the context and user that has registered.
*/
exports.onExecutePostUserRegistration = async (event) => {
      try{
        let url = new URL(event.secrets.SALESFORCE_FORM_URL);
        url.searchParams.set('email', event.user.email ?? '');
        url.searchParams.set('first_name', event.user.given_name ?? '');
        url.searchParams.set('last_name', event.user.family_name ?? '');
        url.searchParams.set('company', event.user.user_metadata.company ?? '');
        url.searchParams.set('visitor_id', event.user.email ?? '');
        url.searchParams.set('status', 'Active');

        const response = await axios.post(url.href);

        if(response.status === 200){
            console.log('Salesforce called');
            console.log(response);
        }
    }catch(e){
        console.log(e);
    }
};

```

Can somebody help me with this? Or give me at least hints how to troubleshoot this?

---

<div class="post-metadata">

**Author:** ![WellBloud](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wellbloud/32/33865_2.png) [@WellBloud](https://community.auth0.com/u/WellBloud)\
**Post date:** [December 20, 2021, 1:29pm UTC](https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111/2 "2021-12-20T13:29:10Z")

</div>

After couple of hours of trial and error I discovered that `event.user.family_name` nor `event.user.given_name` are not available and therefore it was silently failing.

I changed the Login form to put these values into `user_metadata` instead. So now I have this `url.searchParams.set('first_name', event.user.user_metadata.first_name ?? 'Unknown');` and with this it is now working as it should.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 20, 2021, 2:26pm UTC](https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111/3 "2021-12-20T14:26:18Z")

</div>

Thanks for sharing it with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 22, 2021, 3:08pm UTC](https://community.auth0.com/t/post-registration-action-with-salesforce-not-working-for-live-calls/75111/4 "2021-12-22T15:08:18Z")

</div>


