HTTPConnection.Post

Syntax:

Post(<HTTPRequest>, <OutputFileName>)

Parameters:

<HTTPRequest> (required)

Type: HTTPRequest.
HTTP request.

<OutputFileName> (optional)

Type: String.
Name of the file, to which the response body is written.
If it is not set, then the response body can be obtained using the HTTPResponse object.

Returned value:

Type: HTTPResponse.

Description:

Sends data to the specified address for processing using the POST HTTP request.

Availability:

Thin client, server, thick client, external connection, Mobile application (client), Mobile application (server).

Example:

// initialize object for writing XML
RequestFileName = GetTempFileName();
RecordObject = New XMLWriter;
XMLWriterSettings = New XMLWriterSettings("windows-1251", , False);
RecordObject.OpenFile(RequestFileName, XMLWriterSettings);
RecordObject.WriteXMLDeclaration();

// display the Request root element
RecordObject.WriteStartElement("Request");

// display the ClientInfo element
RecordObject.WriteStartElement("ClientInfo");
RecordObject.WriteAttribute("email", SenderAddress);
RecordObject.WriteEndElement();

If 
CertificateFileName <> Undefined Then

    // encode the certificate to Base64 
    DigData.Read(CertificateFileName);
    BaseCertificateFile64 = DigData.GetBaseString64();

    // display the Certificate element
    RecordObject.WriteStartElement("Certificate");
    RecordObject.WriteText(BaseCertificateFile64);
    RecordObject.WriteEndElement();

EndIf
;

If 
ScrambledContainerFileName <> Undefined Then

    // encode encrypted container to Base64
    DigData.Read(ScrambledContainerFileName);
    BaseScrambledContainerFile64 = DigData.GetBaseString64();

    // display the Data element
    RecordObject.WriteStartElement("Data");
    RecordObject.WriteText(BaseScrambledContainerFile64);
    RecordObject.WriteEndElement();

EndIf
;

// writing end for the root element
RecordObject.WriteEndElement();

RecordObject.Close();

OnLineCheckServerAddress = "onlinefc.taxcom.ru";
ResourceAtServer = "/online_fc/online_fc.dll" + ?(GetCertificate, "?IncludeCertificate", "");

// set connection with server
Try
    Joining = New HTTPConnection(OnLineCheckServerAddress, , , , Proxy);
Except
    Message("Couldn't connect to online check server:" 
        + Chars.LF + ErrorInfo().Description, MessageStatus.Important);
    Return
;
EndTry;

// send request
Try
    HTTPRequest = New HTTPRequest(ResourceAtServer);
    HTTPRequest.SetBodyFileName(RequestFileName);
    Result  = Joining.Post(HTTPRequest);
    Joining = Undefined;
    If 
Result.StatusCode > 299 Then
       Message("Status code " + Result.StatusCode + ". Check was not performed.");
    EndIf
;
Except
    Message(ErrorInfo().Description, MessageStatus.Important);
EndTry;


    

1C:Enterprise Developer's Community