top of page
  • androsjuk

Custom service with multi-level JSON request/response

Using data contracts it is possible to build an arbitraty structure of input arguments and return values. For example, we need to update in one request several records and receive a detailed response about success of an operation for each record.

As an input we will receive a list of record identifiers with parameters to be changed

as an output user can receive a list of operation results for each record.

Following steps need to be performed:

  1. Create data contracts for input and output and build a needed tree.

  2. Create a custom service.

  3. Add service to a service group.

  4. Build module.

  5. Run a request with a RESTful services tool (Postman.)

As an example we will take a sales order with sales order lines. Confirmed shupping date and quantity should be updated on each line.

Input contract:

This contract will be an item in a list of an input contract for a sales order:

Then we will define a response.

First we will create a response data contract for a sales line:

Then a response contract for a service method. This method will contain a list of a sales lines' responses:

A response contract looks like this:

Then we will create a service with 1 method updateOrderLines

Create a new service ruaSalesOrderService.

Add operation updateOrderLines to it.

Create new service group ruaServices

Add ruaSalesOrderService to this group.

To call a D365FO service from extern first we need to obtain an authorization token.

A detailed descriptions can be found here.

Service URL should look like this:

A request JSON names should exactly coinside with a parameter names:

A response will look like this:

In this way we can build an arbitrary hierarchie structure with the help of data contracts.

3.269 Ansichten1 Kommentar

Aktuelle Beiträge

Alle ansehen

1 Comment

Gokul Siva
Gokul Siva
Jan 28

My code ttsbegin;

CIT_VendorOutDataResponse lineResponse = new CIT_VendorOutDataResponse();

if(allData == NoYes::Yes)


while select vendTable


select dirPartyTable where dirPartyTable.RecId == vendTable.Party;













ttscommit; My respone output was like this, how do i fix it?


    "$id": "1",

    "Vendor Master": [


            "$id": "2",

            "DataAreaId": "agpc",

            "AccountNum": "VD00045",

            "Vendor Name": "Info Edge (India) Limited - Abu Dhabi",

            "TaxGroup": "DOAUH",

            "Datetime": "2023-10-30T10:58:03Z"




Beitrag: Blog2_Post
bottom of page