Overview Of Graph Developer Proxy

Introduction

Graph Developer Proxy is a tool that simulates API errors using the command line. This tool works for the Microsoft Graph API but can also be extended for other APIs as well. This tool can help applications catch API errors and handle them gracefully. This tool will even help mock the API response so that we do not need to hit the server while developing our application.

Let us first install Graph Developer Proxy in our environment.

Installation

The best feature of Graph Developer Proxy is that it is independent of operating systems so we can use it in any OS (Windows, macOS, or Linux).

To install in Windows OS, follow the below steps,

1. Navigate to the below link, which will take you to the latest version of Graph Developer Proxy.

2. Download the zip file with "win" as the keyword; you can select either x64 or x86 based on your system architecture.

3. Extract the zip file to a location of your choice.

e.g., I have selected "D:\msgraph-developer-proxy-win-x64-v0.5.0"

4. Now add the above-extracted path to the environment variable and run the below command in PowerShell.

$Path = "D:\msgraph-developer-proxy-win-x64-v0.5.0"
$persistedPaths = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) - split ';'
if ($persistedPaths - notcontains $Path) {
    $persistedPaths = $persistedPaths + $Path | where {
            $_
        }
        [Environment]::SetEnvironmentVariable('Path', $persistedPaths - join ';', [System.EnvironmentVariableTarget]::User)
}

Note: Replace the $Path value with the actual value of your Path

Overview of Graph Developer Proxy

Test the Installation

Once the above steps are completed, it's time to check whether our installation was successful. To test, follow the below steps,

1. Open PowerShell or Command Prompt

2. Run the below command

mgdp

Note: If you face an issue such as the command not found, please check whether the environment variable is present.

3. Few additional prompts would be presented the first time, which would require

Trusting the certificate named Titanium Root Certificate Authority

Allowing the firewall access

4. Finally, our Graph Developer Proxy is up and running

Overview of Graph Developer Proxy

Overview of Graph Developer Proxy

Replicate Error 429

To replicate error 429 for all Microsoft graph calls, we can use the below command and check the Microsoft graph API call using Graph Explorer.

mgdp --no-mocks --allowed-errors 429 --failure-rate 100

Let us open Graph Explorer to test our Microsoft Graph API call, returning a 429 error.

Overview of Graph Developer Proxy

Conclusion

It becomes very easy to replicate API errors, especially for Microsoft Graph APIs, as there could be scenarios that would be difficult to replicate without Graph Developer Proxy.


Similar Articles