Monday, February 3, 2025

Push Multiple Records in a Single Http Request Using Batch API in Logic Apps

 Pushing Multiple Records in a Single Request Using Batch API in Logic Apps:

        We can perform the multiple operations in single request by using Batch API. To know more Click Here

Please follow the below steps:

  • I have added the HTTP request.
  • I configured the following URL and headers.
    Content-Type: multipart/mixed; boundary=batch_CR


  • I used the batch number as batch_CR and the change set number as changeset_EE.
  • I am performing three operations:
    • Creating a record in the vendgroup table.
    • Updating a record in the custgroup table.
    • Deleting a record in the vendgroup table
      --batch_CR
      Content-Type: multipart/mixed; boundary=changeset_EE
      
      --changeset_EE
      Content-Type: application/http
      Content-Transfer-Encoding: binary
      Content-ID: 1
      
      POST VendorGroups?cross-company=true HTTP/1.1
      Content-Type: application/json; type=entry
      
      {
          "dataAreaId": "USMF",
          "VendorGroupId": "Test04",
          "Description": "Test 4",
      }
      
      --changeset_EE
      Content-Type: application/http
      Content-Transfer-Encoding: binary
      Content-ID: 2
      
      PATCH CustomerGroups(dataAreaId='USMF',CustomerGroupId= 'TestC01')?Cross-company=true HTTP/1.1
      Content-Type: application/json; type=entry { "Description": "Test C1111" } --changeset_EE Content-Type: application/http Content-Transfer-Encoding: binary Content-ID: 3 DELETE VendorGroups(dataAreaId='USMF',VendorGroupId= 'Test03')?Cross-company=true HTTP/1.1 Content-Type: application/json; type=entry --changeset_EE-- --batch_CR--
  • I used OAuth authentication, providing the Client ID, Secret, and Tenant ID.

Output:

 

If the Batch API request Succeeds:

  1. It returns a 201 status code for the create operation, along with the entire payload of the first request.


  2. It returns a 204 status code for the update and delete operations, as no content is returned after an update and delete.

 

If the Batch API request Fails:

  • The main status code is 200, but within the response body, it returns a 500 error.
  • Below is the output of the Batch API request, with error message highlighted in a green box.

Fetching the Error Message:

  • I added conditions to handle both success and failure cases.

  • If the Batch API request fails, I retrieve the error message using the following expression.
    • Fetch the error
      body('Batch_API')['$multipart'][0]['body']['$multipart'][0]['body']['$applicationHttp']['body']['error']
    • Fetch the error status code
      body('Batch_API')['$multipart'][0]['body']['$multipart'][0]['body']['$applicationHttp']['statusCode']

 

  • If the Batch API request succeeds, I extract the status code using the appropriate expression.
    • Fetch the body
      body('Batch_API')['$multipart'][0]['body']['$multipart'][0]['body']['$applicationHttp']['body']
    • Fetch the status code
      body('Batch_API')['$multipart'][0]['body']['$multipart'][0]['body']['$applicationHttp']['statusCode']



Keep Daxing!!

Monday, January 27, 2025

How to connect UAT data base from dev in D365FO.

How to connect UAT data base(Tier 2) in dev in D365FO.

By default you can connect up to 8 hours after that you have to follow the same process.



1. Log in to LCS and open the UAT environment. Scroll down to find the database account section.

2. Select write ax, provide a description, and click on Request access.


3. Perform a hard refresh, and you should see the following details: Server, Database, User, Password. 

   ServerName/DatabaseName

 

 4. Click on Maintain and select Enable Access.

    

5. Search for "What is my IP" in your dev environment's browser. 

6. Click on Add, then input your IP address and give it a name.

7. Open the K drive and navigate to the AoSService\WebRoot folder. Copy the web.config file and paste it into your local folder. 

Stop the below services before changing the file.

  • IIS
  • World wide publishing
  • MS Dynamics 365 Batch
  • MS Dynamics 365 DIXF
  • Close the VS

8. Make the below changes to the file, then replace the original file in the AoSService\WebRoot folder. Remember to back up the original file before making any changes.   

  • DataAccess.Database
  • DataAccess.DBServer
  • DataAccess.SqlPwd
  • DataAccess.SqlUser
<add key="DataAccess.Database" value="<example_axdb_fromAzure>" />
<add key="DataAccess.DbServer" value="<example_axdb_server.database.windows.net>" />
<add key="DataAccess.SqlPwd" value="<axdbadmin_password_from_LCS>" />
<add key="DataAccess.SqlUser" value="axdbadmin" />
<add key="DataAccess.AxAdminSqlPwd" value="<axdbadmin_password_from_LCS>" />
<add key="DataAccess.AxAdminSqlUser" value="axdbadmin" />

8. Run Command Prompt (CMD) as an administrator and execute the command iisreset.

9. Connect to the SQL server using the provided details.

        1. server name

        2. User name

        3. Password

10. Click on Advanced and Give the data base name and click on connect.

Reference : Click here

Keep Daxing!!