Friday, May 31, 2024

Exploring Third-Party API Interactions with Dynamics 365 F&O(custom services and O data action) and error response details .x++

This blog will refer to how our D365fo Rest API will interact with Third party web Requests.

 

In my scenario, I've encountered timeout and delayed response issues while utilizing a custom service to interact with third-party web requests for importing customer address details. To address these challenges, I conducted thorough research and mentioned them below.

What is API Gateway?

     API gateway is a key component in modern software architecture that acts as an intermediary between client applications and backend services. It provides a unified interface for multiple APIs and manages various aspects of the API lifecycle, including authentication, authorization, traffic management, request/response transformation, and monitoring.

Here's a breakdown of its primary functions:

  1. API Routing: The gateway routes incoming API requests to the appropriate backend service based on predefined rules and configurations.

  2. Authentication and Authorization: It handles authentication mechanisms such as API keys, OAuth, or JWT tokens, ensuring that only authorized clients can access the services.

  3. Traffic Management: API gateways manage and control the flow of incoming requests to prevent overload or abuse. This includes features like rate limiting, throttling, and caching to optimize performance.

  4. Request/Response Transformation: They can transform requests and responses between different data formats (e.g., JSON to XML) or versions to ensure compatibility between clients and services.

  5. Monitoring and Analytics: API gateways provide insights into API usage, performance metrics, error rates, and other analytics to help with troubleshooting, optimization, and decision-making.

  6. Security: They often include features like encryption, data masking, and threat protection to secure the communication between clients and backend services.

How API Gateway works?

    API gateway works by sitting in between clients and services. Once it accepts any client requests, it channels them to the relevant backend services and gathers all the responses together. It routes client requests to various services by acting as a reverse proxy.



What is API gateway timeout?

An API gateway timeout refers to the maximum amount of time that the API gateway will wait for a response from a backend service before terminating the connection and returning an error to the client.

Timeouts are essential for managing the performance and reliability of API interactions. If a backend service takes too long to respond, it can impact the overall responsiveness of the system and potentially lead to resource exhaustion. By setting a timeout, the API gateway ensures that client requests are handled within a reasonable timeframe and prevents them from waiting indefinitely.

API gateway timeouts can be configured based on the specific requirements of the application and the expected response times of backend services. They are typically specified in milliseconds or seconds and can be adjusted to balance between responsiveness and reliability.

Types of API gateway timeout

here are some common types of API gateway timeouts that might occur on specific phases or components:

Connection timeout:

        Occurs when the API gateway can’t connect to the upstream services within the specified time limit. It is often related to network issues or the server being unresponsive.

Request timeout:

    API gateway successfully connects to backend services but doesn’t receive a complete request within the defined time window from the client. Usually happens for large payloads or when client-side communication is slow and laggy.

Response timeout:

    Upstream service takes too long to return a response to the API gateway. This indicates an overloaded or extremely slow service.

Socket timeout:

    Occurs when the API gateway uses a socket for communication with the backend. This timeout indicates how long the socket connection waits for the data.

Global timeout:

    In some API gateways, a global timeout is set that applies to all the requests that pass through the gateway.

Circuit breaker timeout:

    Special type of timeout that helps to prevent excessive load on an unresponsive backend server. This timeout temporarily blocks requests to the server until the server is responsive again.

Response Status details:

1.   If any authentication issue occurs, D365 sends the 401-authentication error to the 3rd party                     system.

2.  If any data violations or any conditional errors or occurred, system will throw the 500 Internal Server Error, while posting because of data processing issue.




3. The HTTP 200 OK success status response code indicates that the request has succeeded.


4. HTTP 400 is a Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error.


Refer the below link to how to create custom service in d365fo using x++




No comments:

Post a Comment