A
A
Alexander Gamov2017-08-22 10:11:41
1C
Alexander Gamov, 2017-08-22 10:11:41

How to catch POST on the 1s side in web services?

Actually, the task is to create an API for data transfer for the subsequent formation of an order on the 1C side.
It was decided to send a post request by the key "params" (temporary name) json string multidimensional array.
The first problem is how to get data from a post request, the only thing I could google is

Ответ = Новый HTTPСервисОтвет(200);
    Ответ.УстановитьТелоИзСтроки(Запрос.ПараметрыЗапроса.Получить("params"));

But here it receives only get parameters.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kinash, 2017-08-22
@slowdream

how to get data from post request

From your question, I did not understand how you are passing data - in a POST JSON object or using multipart/form-data.
In the first case, the text of your POST can be easily obtained using the following construction:
and then you simply create an object with JSON and work with it:
ЧтениеJSON = Новый ЧтениеJSON;
ЧтениеJSON.УстановитьСтроку(POST_txt);
Объект_JSON = ПрочитатьJSON(ЧтениеJSON,,"DOC_DATE");  // важно указать все ваши поля типа даты, что бы потом не парсить вручную строки
ЧтениеJSON.Закрыть();

In the second case, if I'm not mistaken, then you can get the value of the POST parameters using the request method you mentioned Query Parameters() , which returns a match, where the keys are the names of the parameters. But in practice, I have not tested this - GET parameters are quite enough to work with HTML forms, and it is still convenient to write JSON or XML in POST).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question