REST API in 1C: HTTP services, OData and calling external APIs
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
1C has two ways to expose data over REST and one way to consume someone else's API. Your own HTTP services give full control over URLs and responses. The standard OData interface is a ready automatic REST with no code. External APIs are called with HTTPConnection. Below is how they differ and how to test each.
Three ways to work with REST in 1C
An HTTP service is a configuration object where you define URLs, methods and the response format yourself. OData is the platform's automatic REST interface: enabled when publishing, it serves catalogs and documents without code. HTTPConnection is the built-in object for requests from 1C to any external REST API.
What to choose for an integration
If an external system needs to read data as is and fast, start with OData. If you need your own logic, input validation, a stable contract for a partner or JSON in your own format, write an HTTP service. If 1C itself pulls data from a service, marketplace or bank, use HTTPConnection.

How to test a 1C REST API
Test each address from outside, the same way the partner will call it: curl or an API client with the exchange account. Check not only status 200 but the response fields, the answer to invalid data and to missing rights. Run that set of requests after every configuration update.
HTTP service, OData and HTTPConnection side by side
| HTTP service | OData | HTTPConnection | |
|---|---|---|---|
| Direction | 1C serves data | 1C serves data | 1C pulls data |
| Code | Handlers in 1C language | None | Requests in 1C language |
| Address | /hs/root_url/... | /odata/standard.odata/... | Any external |
| Format | Any, usually JSON | JSON or XML | Any |
| Response control | Full | Only object set and rights | Full |

Calling the 1C REST API with curl
# свой HTTP-сервис: корневой URL api, шаблон /orders/{id}
curl -u "Обмен:пароль" "http://erp.example.local/trade/hs/api/orders/5001"
# автоматический REST через OData: первые 5 контрагентов в JSON
curl -u "Обмен:пароль" "http://erp.example.local/trade/odata/standard.odata/Catalog_Контрагенты?\$format=json&\$top=5"The first request goes to your HTTP service, the second to the automatic REST interface. Both need the database published on a web server and an account with rights.
Calling an external REST API from 1C
Соединение = Новый HTTPСоединение("api.example.com", 443, , , , 30,
Новый ЗащищенноеСоединениеOpenSSL);
Запрос = Новый HTTPЗапрос("/v1/orders?status=new");
Запрос.Заголовки.Вставить("Authorization", "Bearer " + Токен);
Запрос.Заголовки.Вставить("Accept", "application/json");
Ответ = Соединение.Получить(Запрос);
Если Ответ.КодСостояния <> 200 Тогда
ВызватьИсключение "API вернул " + Ответ.КодСостояния + ": " + Лев(Ответ.ПолучитьТелоКакСтроку(), 300);
КонецЕсли;
Чтение = Новый ЧтениеJSON;
Чтение.УстановитьСтроку(Ответ.ПолучитьТелоКакСтроку("UTF-8"));
Заказы = ПрочитатьJSON(Чтение, Истина);Checking the status code before parsing JSON avoids cryptic read errors when the service returned an error page. See 1C HTTP request error.
Common errors
- 404 on /hs/. HTTP services are not published or the root URL is wrong.
- 401. No 1C account was sent or it lacks rights.
- OData returns an empty list. The standard interface set is not configured.
- JSON read error from an external API. An HTML page or a BOM arrived.
More on 1C
Section overview and all guides: 1C integration via API: options, architecture and examples.
- 1C HTTP services: create, publish, test and debug with examples
- HTTP requests from 1C: GET, POST, headers, auth and timeouts with examples
- HTTP request failed in 1C: causes and fixes
- OData in 1C: setup, queries and REST integration with examples
- 1C web services (SOAP): create, publish, WSDL and calls with examples
Frequently asked questions
How do I build a REST API in 1C?
Create an HTTP service and publish it, or enable the standard OData interface, which works as automatic REST with no code.
What is the automatic REST service in 1C?
The standard OData interface at /odata/standard.odata/ after publishing and configuring the object set.
How do I call an external REST API from 1C?
With HTTPConnection and HTTPRequest: set the address, headers and auth, send, check the status and read the JSON.
Repeat this on your own API
Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.
Download FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
Start with the linked example and compare its result with your own test requirement.