M
M
monyavitevna2017-03-01 16:22:07
1C-Bitrix
monyavitevna, 2017-03-01 16:22:07

How to create a web service in Bitrix that would compare and update the data in the table received from the request?

Hello. Please help in creating a web service in Bitrix.
I can’t find any detailed instructions on creating web services in Bitrix.
It is necessary to write a simple web service that would compare the data and update the table, depending on the data received in the request. The request will be made from the SQL server.
Those. there is a cash desk in a sporting goods store that works with the Navision program, they organize work there in such a way that when you enter, for example, the number of a bonus card, its status, etc. a request was sent directly to the online store, and the service must accept the variable data and update it in the corresponding table.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-03-01
@shambler81

Do I understand correctly that this will be a sql query?
if so, then Bitrix prohibits working directly with sql, everything should work through the Bitrix API.
Accordingly, you either store data in the Bitrix itself, or use hiload,
or deliberately twist the crutch, and Bitrix has nothing to do with this php + sql

I
Ilya, 2017-03-01
@rpsv

Because it is problematic to write web services in Bitrix out of the box, you need / you can use a regular component.
-
1. Create an 'api.php' page with the following content:

<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");

$APPLICATION->IncludeComponent('site:api', '');

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>

2. Create the component called above ( https://dev.1c-bitrix.ru/learning/course/index.php... ):
<?php

class Api extends CBitrixComponent
{
  function executeComponent()
  {
    // делайте что хотите
  }
}

In the component itself, implement the logic you need, and where necessary, make an AJAX request to the page with the API.
If you create your own tables in the database, then you will need to create your own tools so as not to write stupid SQL queries. You can shit-code, you can make a DataMapper ( https://dev.1c-bitrix.ru/learning/course/?CHAPTER_... ).
If this is difficult for you, or you think that this is not the Bitrx way , then do as Viktor Taran suggested , and stop considering yourself a developer, because. you are nothing more than an administrator.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question