---
title: "@dynatrace-sdk/shared-client-utils"
description: 
---


# @dynatrace-sdk/shared-client-utils



import NpmLogo from '@site/static/img/npm-logo.png';

<div class="row margin-bottom--md">
  <div class="col">
    <a href="https://www.npmjs.com/package/@dynatrace-sdk/shared-client-utils" target="_blank" rel="noopener noreferrer"> <span class="margin-right--xs">@dynatrace-sdk/shared-client-utils</span> <img className="no-zoom" width="20px" src={NpmLogo} /> </a>
  </div>
  <div class="col" style={{textAlign: 'right'}}>
    <a href="https://www.npmjs.com/package/@dynatrace-sdk/shared-client-utils/v/1.0.1" target="_blank" rel="noopener noreferrer">v1.0.1</a>
  </div>
</div>

```bash
npm install @dynatrace-sdk/shared-client-utils
```


## Functions



### apiGatewayErrorsHandler

<div class="padding-bottom--md">
<strong>apiGatewayErrorsHandler(response): Promise&lt;void&gt;</strong>

<div class="padding-left--md">

Handles errors from API Gateway responses.
Throws an ApiGatewayError if the response source is &apos;API Gateway&apos;.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|response<sup>*required</sup>|HttpClientResponse|The HTTP response to check for API Gateway errors. |








</div>





### getErrorMessage

<div class="padding-bottom--md">
<strong>getErrorMessage(errorBody,defaultMessage): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Returns a user-friendly error message from an error body object.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|errorBody<sup>*required</sup>|unknown|The error object or response body to extract the message from. |
|defaultMessage<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|The default message to use if no error message is found. |




#### Returns

| Return type | Description |
|---|---|
|[string](https://developer.mozilla.org/en-US/docs/Glossary/String) | The extracted or default error message, possibly including details.|





</div>





### mimeTypeToEncoding

<div class="padding-bottom--md">
<strong>mimeTypeToEncoding(mimeType,defaultEncoding?): Encoding</strong>

<div class="padding-left--md">

Maps a MIME type string to an Encoding.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|mimeType<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|The MIME type to convert (e.g., 'application/json'). |
|defaultEncoding|Encoding|The encoding to return if the MIME type isn't recognized. |




#### Returns

| Return type | Description |
|---|---|
|Encoding | The corresponding Encoding enum value, or the defaultEncoding if not recognized.|





</div>





### toQueryString

<div class="padding-bottom--md">
<strong>toQueryString(rawQuery?,flags?): [string](https://developer.mozilla.org/en-US/docs/Glossary/String)</strong>

<div class="padding-left--md">

Converts an object of query parameters into a URL query string.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|rawQuery|QueryParamsType|The object containing query parameters. |
|flags|[ParametersFlags](#parametersflags)|Flags to control parameter formatting (e.g., explode arrays). |




#### Returns

| Description |
|---|
|The resulting query string.|





</div>





### transformFromFormData

<div class="padding-bottom--md">
<strong>transformFromFormData(formData,fields): T</strong>

<div class="padding-left--md">

Converts form data and field definitions into a typed object, applying transformations for JSON fields.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|formData<sup>*required</sup>|FormDataResponseBody|The form data to convert. |
|fields<sup>*required</sup>|Record&lt;[string](https://developer.mozilla.org/en-US/docs/Glossary/String) &#124; FormDataResponseFieldDefinition&gt;|The field definitions for the form data. |




#### Returns

| Return type | Description |
|---|---|
|T | The resulting typed object.|





</div>





### transformRequest

<div class="padding-bottom--md">
<strong>transformRequest(object,rules): T</strong>

<div class="padding-left--md">

Transforms an object by applying transformation rules before sending it in a request.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|object<sup>*required</sup>|T|The object to transform. |
|rules<sup>*required</sup>|TransformRulesParam|The transformation rules to apply. |




#### Returns

| Return type | Description |
|---|---|
|T | The transformed object.|





</div>





### transformResponse

<div class="padding-bottom--md">
<strong>transformResponse(object,rules): T</strong>

<div class="padding-left--md">

Transforms an object by applying transformation rules after receiving it in a response.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|object<sup>*required</sup>|T|The object to transform. |
|rules<sup>*required</sup>|TransformRulesParam|The transformation rules to apply. |




#### Returns

| Return type | Description |
|---|---|
|T | The transformed object.|





</div>





### transformToFormData

<div class="padding-bottom--md">
<strong>transformToFormData(value,fields): FormDataRequestBody</strong>

<div class="padding-left--md">

Converts an object to a FormDataRequestBody using field definitions.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|value<sup>*required</sup>|T|The object to convert. |
|fields<sup>*required</sup>|Array&lt;[FormDataRequestFieldDefinition](#formdatarequestfielddefinition)&gt;|The field definitions for the form data. |




#### Returns

| Return type | Description |
|---|---|
|FormDataRequestBody | The resulting form data body.|





</div>





### transformToFormDataField

<div class="padding-bottom--md">
<strong>transformToFormDataField(value,field): FormDataRequestField &#124; null</strong>

<div class="padding-left--md">

Converts a value to a FormDataRequestField based on the field definition.



</div>


#### Parameters

| Name | Type | Description |
| --- | --- | --- |
|value<sup>*required</sup>|T|The value to convert. |
|field<sup>*required</sup>|[FormDataRequestFieldDefinition](#formdatarequestfielddefinition)|The field definition. |




#### Returns

| Return type | Description |
|---|---|
|FormDataRequestField \| null | The resulting form data field or null if not required and undefined.|





</div>



## Interfaces

### ApiClientOptions
Configuration for the API client.


#### Properties

| Name | Type |
| --- | --- |
|transformDates<sup>*required</sup>|[boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)| 


### FormDataRequestFieldDefinition



#### Properties

| Name | Type |
| --- | --- |
|key<sup>*required</sup>|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)| 
|required<sup>*required</sup>|[boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)| 
|type<sup>*required</sup>|"text" &#124; "json" &#124; "binary"| 


### FormDataResponseGenericFieldDefinition



#### Properties

| Name | Type |
| --- | --- |
|type<sup>*required</sup>|"text" &#124; "binary"| 


### FormDataResponseJsonFieldDefinition



#### Properties

| Name | Type |
| --- | --- |
|transformations<sup>*required</sup>|Array&lt;[string](https://developer.mozilla.org/en-US/docs/Glossary/String) &#124; &gt;| 
|type<sup>*required</sup>|"json"| 


### ParametersFlags



#### Properties

| Name | Type |
| --- | --- |
|explode|Record&lt;[string](https://developer.mozilla.org/en-US/docs/Glossary/String) &#124; [boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)&gt;| 


