Language:


REST API - Requests and Responses in JSON format

This page describes using the Standard ERP API to make requests and to get responses in JSON format. Please refer to the following pages for details about other aspects of the API:
---
If you need requests and/or responses to be in JSON format, you will need to include an instruction to this effect in the header of the request. For example, the header of a GET request requiring a response in JSON format should contain "-H "Accept: application/json"":
curl -X GET -H "Accept: application/json" 'http://hostname.domain.top:web port/api/1/IVVc'
You can use parameters in the way described here to refine GET requests. For example:
curl -X GET -H "Accept: application/json" 'http://hostname.domain.top:web port/api/1/IVVc?sort=CustCode'
POST and PATCH requests in which the request is in JSON format should contain "-H "Content-Type: application/json"" in their headers. In this example PATCH request, the request is in JSON format and a JSON response is required:
curl -X PATCH \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"data":{"IVVc":[{"Addr1":"New Address Line 1","Addr2":"New Address Line 2"}]}}' \
'http://hostname.domain.top:web port/api/1/IVVc/10000014'
This will change the first two lines of the Invoice Address in Invoice 10000014 to "New Address Line 1" and "New Address Line 2" (the Addr1 and Addr2 fields in IVVc).

With POST only, you can create more than one record with the same request:

curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"data":{"ObjVc":[{"Code":"TEST1","Comment":"Test 1","OTCode":"PERS"},{"Code":"TEST2","Comment":"Test 2","OTCode":"PERS"}]}}' \
'http://hostname.domain.top:web port/api/1/ObjVc?fields=Code,Comment,OTCode'
This will create two Objects TEST1 and TEST2 belonging to the "PERS" Object Type, and the response will only display the Code, Comment and Object Types of those new Objects.

The following example will create a Quotation with two rows. Note that row numbers begin at 0:

curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"data":{"QTVc":[{"CustCode":"005","PayDeal":"30","Addr0":"Agent - Polani Travel","QTDate":"2022-04-27","QuoteClass":"V","CurncyCode":"GBP","ToRateB1":"","FrRate":"", "ToRateB2":"","BaseRate1":"0.8952","BaseRate2":"1","Sum1":"42.00","Sum3":"8.40","Sum4":"50.40", "ExportFlag":"0","rows":[{"@rownumber":"0","ArtCode":"10101","Spec":"Transistor Radio","SalesAcc":"100","VATCode":"1","Objects":"AUDIO","Price":"25.00","Quant":"1.000","Sum":"25.00"},{"@rownumber":"1","ArtCode":"10104","Spec":"Loudspeakers","SalesAcc":"100","VATCode":"1", "Objects":"AUDIO","Price":"17.00","Quant":"1.000","Sum":"17.00"}]}]}}' \
'http://hostname.domain.top:web port/api/1/QTVc'
Note that if you use set_field and set_row_fields) in a POST request, all window actions and all record actions will be carried out. But if you submit a POST request in JSON format, only the record actions will be carried out. This means for example that when sending a Customer Number to a new Invoice, information such as the Customer Name, Payment Term and Price List will not be brought in to the Invoice so you will need to include this information in the request. The record validation check on saving will be carried out so a record will not be saved if there is a problem, and the relevant error message will be included in the JSON response.

---

The Standard ERP REST API:

Go back to: