Delphi RESTClient POST 请求

Delphi RESTClient POST request

嗯,我正在开发一个 REST 客户端应用程序,它需要使用 application/x-www-form-urlencoded 作为内容类型发送 POST 请求。我正在使用 Delphi 的默认 REST.Client 组件。我需要以 XML 格式发送数据,如下例所示:

    data=<serviceLocal>
    <description>Francisco Hansen</description>
    <active>true</active>
    <corporateName>Francisco Hansen</corporateName>
    <country>Brasil</country>
    <state>PR</state>
    <city>Pato Branco</city>
    <cityNeighborhood>Centro</cityNeighborhood>
    <streetType>Rua</streetType>
    <street>Tocantins</street>
    <streetNumber>2334</streetNumber>
    <streetComplement>Ap101</streetComplement>
    <zipCode>85501-272</zipCode>
    <cellphoneStd>46</cellphoneStd>
    <cellphoneNumber>99999999</cellphoneNumber>
    <phoneStd>46</phoneStd>
    <phoneNumber>99999999</phoneNumber>
    </serviceLocal>

如何将所有这些作为 POST 参数添加到 TRestRequest,然后使用 TRestClient 发送此请求?

使用 Rest.Client.TRESTRequest 组件,我已经能够为请求设置 POST 参数。我将 TRESTRequest 命名为 rqst1

.

rqst1.Method := rmPost;

rqst1.Params.AddItem; //Adds a new Parameter Item
rqst1.Params.Items[0].name := 'data'; //sets the name of the parameter. In this case, since i need to use 'data=' on the request, the parameter name is data.
rqst1.Params.Items[0].Value := params; //Adds the value of the parameter, in this case, the XML data.
rqst1.Params.Items[0].ContentType := ctAPPLICATION_X_WWW_FORM_URLENCODED; //sets the content type.
rqst1.Params.Items[0].Kind := pkGETorPOST; //sets the kind of request that will be executed.