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


# @dynatrace-sdk/shared-client-utils





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


## Functions


<a name="apigatewayerrorshandler"></a>
### 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>




<a name="geterrormessage"></a>
### 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>




<a name="mimetypetoencoding"></a>
### 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>




<a name="toquerystring"></a>
### 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|<a href="#parametersflags">ParametersFlags</a>|Flags to control parameter formatting (e.g., explode arrays). |




#### Returns

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





</div>




<a name="transformfromformdata"></a>
### 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>




<a name="transformrequest"></a>
### 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>




<a name="transformresponse"></a>
### 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>




<a name="transformtoformdata"></a>
### 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;<a href="#formdatarequestfielddefinition" target="_blank" rel="noopener noreferrer">FormDataRequestFieldDefinition</a>&gt;|The field definitions for the form data. |




#### Returns

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





</div>




<a name="transformtoformdatafield"></a>
### 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>|<a href="#formdatarequestfielddefinition">FormDataRequestFieldDefinition</a>|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;| 


