POST getUserData

{{domainAddress}}/customData/getUserData

Important: This function must be requested before the following UIs are accessed:

  • Registration of a new user (some registrations require the collection of this additional data)
  • Displaying a customer’s previously collected data

The response to this request provides previously recorded customer data to be used to populate the UI with the necessary input components.

Headers

HeaderContent
Content Typeapplication/json
AuthorizationBearer {{ID token}}
App-Id{{API key provided by Mosaic}}
Device-Id{{Advertising ID from the initial installation of this app}}
Request-Date{{ISO 8601 date and time format in UTC}}

Body

This function requires the clientId provided by Mosaic for this app to be sent in the request payload.

{
"clientId": "{{clientId}}",
"userId": "{{userId}}"
}

Example

Headers
App-Id: 5***9-d**3-4**8-b**1-b3***dac
Device-Id: a4***cb-d***5-4***f-8***c-84***75
Request-Date: 2024-07-02T19:59:20.815Z
Content-Type: application/json
Authorization: Bearer eyJraWQiO...aLxlc6PCgQ
Body
{
"clientId": "{{clientId}}",
"userId": "{{userId}}"
}

Response

Retain the response.data contents in local storage.  

There are two outcomes to this request:

  1. The customer has no previously recorded data, or
  2. The customer has existing data.

Customer has no data

The response.data object will be empty.

{
"errors": [],
"warnings": [
"Validator: 1 value was removed from the provided request data"
],
"notices": [],
"data": {}
}

Customer has previously recorded data

The response.data object will contain the previously recorded data for this customer. The fieldId value will map to the input field IDs. The values for subFieldA and subFieldB can be used to populate the text field(s) and dropdown menu selection(s).

Each object in the result.data object will contain an array. Each object in the array represents an instance of the input component. By default there will be only one object in the array, however, if the configuration data for the input permits the user to add additional instances, there may be multiple objects in the array. Add the UI components and populate each using the corresponding data object.

{
"errors": [],
"warnings": [
"Validator: 1 value was removed from the provided request data"
],
"notices": [],
"data": {
"field1": [
{ <-- only one input component
"fieldId": "field1",
"subFieldA": "Andy 123",
"subFieldB": " "
}
],
"field2": [
{ <-- two input components
"fieldId": "field2",
"subFieldA": "Option A:A",
"subFieldB": " "
},
{
"fieldId": "field2",
"subFieldA": "Option B:B",
"subFieldB": " "
}
],
"field3": [
{ <-- two input components
"fieldId": "field3",
"subFieldA": "My text",
"subFieldB": "Option3:3"
},
{
"fieldId": "field3",
"subFieldA": "More text",
"subFieldB": "Option4:4"
}
]
}
}

Error Codes

Important: To determine whether or not to parse the response.data object as a successful response, or an error response, examine the errors array. If its length is greater than zero, then the data contains an error data structure.

Authentication Errors

All API functions are subject to possible authentication errors. These are consistent across all function and are described in the Authentication post.

API ResponseCause
response: { “message”: “Unauthorized” }Incorrect headers or header contents. Contact Mosaic Developers to resolve this issue.
response.data:{ “message”: “Access Token has expired”, “code”: “NotAuthorizedException“, “statusCode”: 400, “retryable”: false }Refresh tokens The access token previously recorded is no longer valid, and must be refreshed. The “message” will explain what went wrong.