---
title: Response
slug: netsuite/response
description: Learn how to handle response data from request calls in this document. Understand the structure of the response, which is in the form of a Map<String, Object>, and explore the keys and their values, including version, action, timestamp, and more. Addition
docTags: 
createdAt: 2021-09-14T13:58:58.000Z
---

This response is the information returned from the Request call.  This will be returned in the form of a Map\<String, Object>.

Below are the list of Keys or Parameters returned in the Response Map:

| **Key (String)** | **Value (Object)**                                                  | **Additional Detail**                                                                            |
| ---------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| version          | ‘1.0’                                                               | Returns the same version sent in the Request                                                     |
| action           | See the list of available actions.                                  | Returns the same action sent in the Request.                                                     |
| timestamp        | Timestamp in milliseconds (Unix).                                   | The time at which the Response was returned.  This can be used to troubleshoot.                  |
| validRequest     | Either true or false.                                               | True if the Request satisfies the Breadwinner validations; False if it does not                  |
| apiErrors        | Returns [Error](docId\:Lps5Q5vqcWrV0uJEnpbLs) list as a JSON string | List of errors that occurred while validating the request before making the request to NetSuite. |
| responseJSON     | Returns the response of the record(s) as a JSON string.             | Includes the records data as well as any errors that were sent to Breadwinner from NetSuite.     |

### Error

| **Key (String)** | **Data Type** | **Description**                                                                                                                           |
| ---------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| code             | String        | A short string indicating the error code reported.                                                                                        |
| message          | String        | A detailed explanation of the Error occurred. Example: Breadwinner was unable to process the request as the action parameter was invalid. |

## Errors

### Before requesting NetSuite

Errors that occur while validating the request, or while making a request to NetSuite are returned as ‘apiErrors’ in the response.&#x20;

### After requesting NetSuite

Errors occurred within NetSuite while processing the request, or while processing the data in Breadwinner are sent as ‘errors’ in the responseJSON key of the Response map.

### Examples

:::::Tabs
::::Tab{title="Validation Error"}
Breadwinner does validation prior to calling out to NetSuite.

:::CodeblockTabs
Invalid Request

```json
{
    action=readCustomer, 
    apiErrors={"errors":[
        {"message":"Breadwinner was unable to process the request as the version parameter was not valid.",
        "code":"INVALID_VERSION"
        }
        ]
        }, 
    timestamp=1635186915365, 
    validRequest=false, 
    version=1.1
}
```
:::
::::

::::Tab{title="Error returned from NetSuite"}
This is an error sent back from NetSuite that was reformatted for easier reading.

:::CodeblockTabs
400

```json
{
  action=createCustomer,
  responseJSON={
    "customers": null,
    "errors": [
      {
        "message": "Please enter value(s) for: First Name, Last Name",
        "code": "USER_ERROR"
      }
    ],
    "status": "400"
  },
  timestamp=1635239587001,
  validRequest=true,
  version=1.0
}
```
:::
::::
:::::

### Sample Structure on how to parse the Response

:::CodeblockTabs
Apex

```apex
if(respMap.containsKey('apiErrors') &&  respMap.get('apiErrors')!=null){
    // add any custom apex code.
}
else if(respMap.containsKey('responseJSON')  &&  String.isNotBlank((String)respMap.get('responseJSON'))){
    Response responseReturn = new Response();
    Map<String,Object> soResponseJSONMap = (Map<String,Object>)JSON.deserializeUntyped((String)respMap.get('responseJSON'));

    if(soResponseJSONMap !=NULL && soResponseJSONMap.containskey('status') && soResponseJSONMap.get('status')!=null){
        responseReturn.statusCode = (String)soResponseJSONMap.get('status');
    }

    if(soResponseJSONMap !=NULL && soResponseJSONMap.containskey('salesOrders') && soResponseJSONMap.get('salesOrders')!=null){
        List<Object> soObj = (List<Object>)soResponseJSONMap.get('salesOrders');
        Map<String,Object> savedSO = (Map<String,Object>)soObj[0];
        responseReturn.recordId = (String)savedSO.get('salesforceID');
    }

    if(soResponseJSONMap !=NULL && soResponseJSONMap.containskey('errors') && soResponseJSONMap.get('errors')!=null){    
        responseReturn.error = JSON.serialize((List<Object>)soResponseJSONMap.get('errors'));
    }
    //return responseReturn;
}
```
:::




