# Post User Registration Action ERROR

**URL:** <https://community.auth0.com/t/post-user-registration-action-error/87680>\
**Category:** Get Help\
**Tags:** actions, auth0\
**Created:** [July 26, 2022, 4:20pm UTC](https://community.auth0.com/t/post-user-registration-action-error/87680 "2022-07-26T16:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuadacosta0311](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joshuadacosta0311/32/35348_2.png) [@joshuadacosta0311](https://community.auth0.com/u/joshuadacosta0311)\
**Post date:** [July 26, 2022, 4:20pm UTC](https://community.auth0.com/t/post-user-registration-action-error/87680/1 "2022-07-26T16:20:02Z")

</div>

Hey!

I’ve been mulling over this for ages, I am trying to fire off a function post user registration to my GQL API, but it keeps returning a 400. Now, if I hard code the values, rather than using string interpolation, it works! But using string interpolation always results in an error! Its really frustrating. Please see below for code snippet, would love any advice!

```auto
const axios = require("axios");

exports.onExecutePostUserRegistration = async (event) => {
  console.log(event.user.email)
  console.log(event.user.username)
  console.log(event.user.user_id)

 await axios({
   url: 'https://rome-gql.herokuapp.com/',
   method: 'post',
   data: { query: `mutation Signup {
  signup(credentials: {email: ${event.user.email}, username: ${event.user.username}, sub: ${event.user.user_id}}) {
    userErrors {
      message
    }
  }
}`
   }
  })
   .then(res => {
    console.log(res.data);
   })
   .catch(err => {
    console.log(err);
    console.log('Got here')
   });

};

```

**Full Error Log -**

```auto
Commands:
[]
Error:
{}
Logs:
j+smith@example.com
j+smith
auth0|5f7c8ec7c33c6c004bbafe82
[AxiosError: Request failed with status code 400] {
  code: 'ERR_BAD_REQUEST',
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [Function: httpAdapter],
    transformRequest: [[Function: transformRequest] ],
    transformResponse: [[Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function] },
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'axios/0.27.2',
      'Content-Length': 188
    },
    url: 'https://rome-gql.herokuapp.com/',
    method: 'post',
    data: '{"query":"mutation Signup {\\n signup(credentials: {email: j+smith@example.com, username: j+smith, sub: auth0|5f7c8ec7c33c6c004bbafe82}) {\\n userErrors {\\n message\\n }\\n }\\n}"}'
  },
  request: <ref *1> ClientRequest {
    _events: [Object: null prototype] {
      abort: [Function (anonymous)],
      aborted: [Function (anonymous)],
      connect: [Function (anonymous)],
      error: [Function (anonymous)],
      socket: [Function (anonymous)],
      timeout: [Function (anonymous)],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    maxRequestsOnConnectionReached: false,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: null,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    _closed: false,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: false,
      _SNICallback: null,
      servername: 'rome-gql.herokuapp.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'rome-gql.herokuapp.com',
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(async_id_symbol)]: 70,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object],
      [Symbol(RequestTimeout)]: undefined
    },
    _header: 'POST / HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'Content-Type: application/json\r\n' +
      'User-Agent: axios/0.27.2\r\n' +
      'Content-Length: 188\r\n' +
      'Host: rome-gql.herokuapp.com\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _keepAliveTimeout: 0,
    _onPendingData: [Function: nop],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype],
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'POST',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    path: '/',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      socket: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      rawHeaders: [Array],
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 400,
      statusMessage: 'Bad Request',
      client: [TLSSocket],
      _consuming: false,
      _dumped: false,
      req: [Circular *1],
      responseUrl: 'https://rome-gql.herokuapp.com/',
      redirects: [],
      [Symbol(kCapture)]: false,
      [Symbol(kHeaders)]: [Object],
      [Symbol(kHeadersCount)]: 16,
      [Symbol(kTrailers)]: null,
      [Symbol(kTrailersCount)]: 0,
      [Symbol(RequestTimeout)]: undefined
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: 'rome-gql.herokuapp.com',
    protocol: 'https:',
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 188,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [Circular *1],
      _currentUrl: 'https://rome-gql.herokuapp.com/',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      'user-agent': [Array],
      'content-length': [Array],
      host: [Array]
    }
  },
  response: {
    status: 400,
    statusText: 'Bad Request',
    headers: {
      server: 'Cowboy',
      connection: 'close',
      'access-control-allow-origin': '*',
      'content-type': 'application/json; charset=utf-8',
      'content-length': '131',
      etag: 'W/"83-b8enmKeSK3P/aRndq5jl4zxKRok"',
      date: 'Tue, 26 Jul 2022 16:19:27 GMT',
      via: '1.1 vegur'
    },
    config: {
      transitional: [Object],
      adapter: [Function: httpAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: [Object],
      validateStatus: [Function: validateStatus],
      headers: [Object],
      url: 'https://rome-gql.herokuapp.com/',
      method: 'post',
      data: '{"query":"mutation Signup {\\n signup(credentials: {email: j+smith@example.com, username: j+smith, sub: auth0|5f7c8ec7c33c6c004bbafe82}) {\\n userErrors {\\n message\\n }\\n }\\n}"}'
    },
    request: <ref *1> ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST / HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'User-Agent: axios/0.27.2\r\n' +
        'Content-Length: 188\r\n' +
        'Host: rome-gql.herokuapp.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'rome-gql.herokuapp.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    data: { errors: [Array] }
  }
}
Got here
Stats:
{
  "total_request_duration_ms": 472,
  "total_runtime_execution_duration_ms": 470,
  "runtime_processing_duration_ms": 7,
  "action_duration_ms": 429,
  "runtime_external_call_duration_ms": 34,
  "boot_duration_ms": 41,
  "network_duration_ms": 3
}

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 27, 2022, 12:01am UTC](https://community.auth0.com/t/post-user-registration-action-error/87680/4 "2022-07-27T00:01:19Z")

</div>

Hello there @joshuadacosta0311 welcome to the community!

Thanks for the detailed description of the issue at hand 😄 I’m unfortunately not seeing anything on first glance that sticks out to me as a potential issue - The data `{email: ${event.user.email}, username: ${event.user.username}, sub: ${event.user.user_id}` all looks good to me in terms of what Auth0 is sending. Good to know that hard coding the values works, at least you’re getting there!

Silly question, but are you positive the payload matches what’s expected by your API? That is often the case with this sort of error/use case.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [August 11, 2022, 12:01am UTC](https://community.auth0.com/t/post-user-registration-action-error/87680/5 "2022-08-11T00:01:54Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
