Test custom services using raw HTTP

You will need a client id and client secret.
The client should be registered in D365F&FSC at System administration -> Setup -> Azure Active Directory applications
All requests were tested using Fiddler and its Composer -> Scratchpad feature.
You can find the implementation of the calc service following this link.
The following tools can be used to issue HTTPS requests:
  • Postman
  • Fiddler
There are a couple of examples of how you can test your services:

API (JSON)

Make sure that empty line which dividing HTTP headers and body is empty, without space. Otherwise you will most probably get an error.

Request to get auth token:
POST https://login.windows.net/{TenantId}/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: login.windows.net

resource=https://{D365FO-URL}&client_id={ClientId}&client_secret={ClientSecret}&grant_type=client_credentials
TenantId - Open D365FO / ? (Sign at top right corner) / About / Licenses / This product is licensed to

Request to service:
POST https://{aos}.cloudax.dynamics.com/api/Services/VKOServiceGroup/VKOCalcService/calc HTTP/1.1
Content-Type: application/json
Accept: application/json
Accept-Charset: UTF-8
Authorization: Bearer {AuthToken}
Host: {aos}.cloudax.dynamics.com

{
"_calcContract":
    {
         "arg1": 2,
         "arg2": 2,
         "operation": 0,
         "list": [{
             "a": 0,
         },
         {
             "a": 1,
         }],
         "subCalc": {
             "a": 5
         }
    }
}

SOAP


SoapUI can form a correct request for you using wsdl https://{aos}.cloudax.dynamics.com/soap/Services/VKOServiceGroup?wsdl
You can use SoapUI to send request, you just need to manually add Authorization header with value Bearer {AuthToken}

Example of SOAP request:
POST https://{aos}.cloudax.dynamics.com/soap/services/VKOServiceGroup HTTP/1.1
Content-Type: text/xml
SOAPAction: http://tempuri.org/Calc/calc
Authorization: Bearer {AuthToken}
Host: {aos}.cloudax.dynamics.com

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://schemas.microsoft.com/dynamics/2013/01/datacontracts" xmlns:tem="http://tempuri.org" xmlns:dyn="http://schemas.datacontract.org/2004/07/Dynamics.AX.Application">
   <soapenv:Header>
   </soapenv:Header>
   <soapenv:Body>
      <tem:calc>
         <tem:_calcContract>
            <dyn:List>
               <dyn:SubCalc>
                  <dyn:a>1</dyn:a>
               </dyn:SubCalc>
            </dyn:List>
            <dyn:arg1>2</dyn:arg1>
            <dyn:arg2>2</dyn:arg2>
            <dyn:operation>0</dyn:operation>
            <dyn:subCalc>
               <dyn:a>1</dyn:a>
            </dyn:subCalc>
         </tem:_calcContract>
      </tem:calc>
   </soapenv:Body>
</soapenv:Envelope>
SOAPAction: http://tempuri.org/{External Name property from service}/calc

C#

http://dev.goshoom.net/en/2017/02/json-based-custom-service-with-parameters/

 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags