httpPost

Runs an HTTP Post request and returns the HTTP response from the server. Also see callPostMethod.

The content type provided in the request's header is set by default to application/json. Use this function when the endpoint expects a JSON object parameter.

This is suitable for all modules of business service components.

Syntax

Copy
function httpPost(url: string, body: any, timeout?: number, customHeaders?: any): IFtosHttpResult
function httpPost(url: string, body: any, options?: IFtosHttpGetOptions): IFtosHttpResult
 
Parameter Type Description
url string The service endpoint's URI. For instance, the address of a REST API endpoint.
body optional any Key-value pairs in JSON format to be passed in the request's body.
timeout optional number Maximum number of seconds to wait for the HTTP response.
customHeaders optional any Key-value pairs in JSON format to be passed in the request's custom headers.
options (optional) IFtosHttpGetOptions Additional options to be passed to the HTTP request.

Type Aliases

Return Value

Returns the HTTP response of the HTTP Post request. For example:

Copy
{
    "IsSuccess": true,
    "Response": {
        "NumberOfResults": 0,
        "TotalNumber": 0,
        "RequestedSkip": 0,
        "RequestedTake": 0,
        "Records": [
            {
                "previousBSId": "d056648b-fb96-4210-b253-6de285f27c48",
                "businessStatusId": "cfad132f-d24b-49b3-a7ac-73d5b6905902",
                "nextBusinessStatusId": null,
                "ServerSDKTestid": "e796bdd6-efe6-43e6-b76a-6842d3197735",
                "method": "M2",
                "userId": "4afdc8a9-eb91-4359-81d6-c3a462fae866",
                "createdByUserId": "4afdc8a9-eb91-4359-81d6-c3a462fae866",
                "modifiedByUserId": "4afdc8a9-eb91-4359-81d6-c3a462fae866",
                "businessUnitId": "a3d2909b-df67-49d6-b7e0-2dc912c12484",
                "createdOn": "2020-01-10T10:24:48Z",
                "modifiedOn": "2020-01-31T13:58:25Z",
                "entityStatusId": "faccc388-151a-4c83-8953-cbac7d6c442a",
                "file": "[{\"Name\":\"Quote_and_Buy_extended_data_model.png\",\"RealName\":\"Quote_and_Buy_extended_data_model_d9bf2c95-ab7d-4acc-befb-4b5d448f09f6.png\",\"IsSuccess\":true,\"Message\":null,\"ClientScript\":null,\"Serialized\":null,\"ErrorCode\":0,\"UIResult\":null}]",
                "primaryattributedisplayname": "Methodology",
                "aLookup1_name": "status2",
                "previousBSId_displayname": "status2",
                "aLookup2_name": "status3",
                "businessStatusId_displayname": "status3",
                "aLookup3_name": null,
                "nextBusinessStatusId_displayname": null,
                "aLookup4_userName": "jdoe",
                "userId_displayname": "jdoe",
                "aLookup5_userName": "jdoe",
                "createdByUserId_displayname": "jdoe",
                "aLookup6_userName": "jdoe",
                "modifiedByUserId_displayname": "jdoe",
                "aLookup7_name": "root",
                "businessUnitId_displayname": "root",
                "aLookup8_name": "Active",
                "entityStatusId_displayname": "Active"
            }
        ],
        "Message": null,
        "IsSuccess": true,
        "ClientScript": null,
        "Serialized": null,
        "ErrorCode": 0,
        "UIResult": null
    },
    "StatusCode": 200
}

If the response is returned in JSON format, the following properties are supported by the return value, corresponding to its first level keys: .IsSuccess, .Response, and .StatusCode.

NOTE  
The Response key in the result is a JSON object, not a string as when using the callGetMethod function.

Examples