J
J
jokker7911122019-06-02 06:35:05
1C-Enterprise
jokker791112, 2019-06-02 06:35:05

Sending from 1C POST request with xml file?

There is a link to some resource, for example: info.eks.com/eservice.aspx?username=123456789, to which you need to send a POST request.
Wrote a procedure:
ServerName = "info.eks.com";
HTTP = New HTTPConnection(ServerName,);
// Get a temporary file to send in the POST request body
FileRequestBody = GetTemporaryFileName();
RecordObject = New XML Record;
RecordObject.OpenFile(RequestBodyFile);
ObjectRecord.WriteDeclarationXML();
ObjectRecord.WriteItemStart("xml");
ObjectRecord.WriteItemStart("info");
RecordObject.WriteItemStart("requestType");
ObjectRecord.WriteText("1");
ObjectRecord.WriteEndElement();
ObjectRecord.WriteEndElement();
RecordObject.WriteItemStart("request");
ObjectRecord.WriteItemStart("inn");
ObjectRecord.WriteText("078596354");
ObjectRecord.WriteEndElement();
ObjectRecord.WriteEndElement();
ObjectRecord.WriteEndElement();
ObjectRecord.Close();
//
// Get a temporary file — the body of the POST request
response FileResult = GetTemporaryFileName();
// Sending a POST request for processing.
Login = "123456789";
HTTPRequest = New HTTPRequest("/eservice.aspx");
HTTPRequest.SetBodyFromString("
HTTPRequest.SetBodyFileName(RequestBodyFile);
Result = HTTP.SendForProcessing(HTTPRequest,FileResult);
But for some reason it does not work, what could I be wrong about?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kinash, 2019-06-02
@Dementor

To debug interaction with external servers, I recommend using tools like Fiddler ( article on Habré ) - this way you can check the packet that you form and send, as well as the entire server response (headers and body).
Are you aware that the files are not needed at all? If you do a SetString() on an XMLWriter, then when it closes it will return the resulting string. Next, you can set the HTTP request body using SetBodyFromString(). And if you do not specify the second parameter for the SendForProcessing() function, then it will return an HTTPResponse from which you can read all the necessary information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question