Solutions to Common API Issues With Megaport

Solutions to Common API Issues With Megaport

By Gary Taylor, Solutions Architect

This detailed guide gives you 11 solutions to common API problems, so you can automate and streamline your deployments with ease.

With automation pervading the networking world in recent years, APIs have become standard for software and IT specialists. While the jury is out on the exact number of public APIs offered today, all estimates point to their massive (and ever-growing) popularity.

Megaport is one of the many thousands of vendors that provides public API access to all our services, enabling our customers to automate and streamline their deployments.

Get started with our API Overview documentation.

But for those still familiarizing themselves with a new set of APIs, it can be overwhelming to determine the cause of an error. That’s why we’ve put together this beginner-friendly guide, with 11 step-by-step solutions to common API issues, so you can bookmark and come back to it whenever you need.

HTTP status codes

If you aren’t already familiar, we recommend first memorizing these HTTP status codes. When they appear, they can offer valuable insight as to what your issue may be.

Code

Meaning

200

OK. A successful request.

400

Bad request. This error is typically caused by missing or incorrect request parameters.

401

Unauthorized. This error indicates the request is missing the required authentication credentials, usually a missing or invalid API access token.

403

Forbidden. You do not have the required permissions to perform this request.

500

Server error. When this occurs, Megaport developers are notified of the error via email from the server.

503

Server is unavailable, possibly down for maintenance.

If you’re using Postman and following our setup guide ‘Creating an API Key’, the following suggestions can help with a number of common errors.

1. Check the correct request type is being used

When creating a request, using the incorrect request type (GET, PUT, POST, etc.) can result in errors like the below:

Incorrect request type error

The error message for this issue is usually self-explanatory:

{
   "message": "Request method 'POST' not supported",
   "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
   "data": [
       "Unsupported Http Methods: POST",
       "Supported Http Methods: [GET]"
   ]
}

To avoid this error, make sure you use the correct request type.

Correct request type

2. Check the correct URL for token authentication

After first generating an access token (which is done as a POST request), the URL you enter will depend on whether you’re using our staging or production environment. Not using the correct URL will cause the error below:

{
   "error": "invalid_client"
}

Include the correct token authentication URL for your API:

  • https://api.megaport.com/: This is the live production environment. You will be liable for any services ordered in this system.
    • The token authentication URL for production is https://auth-m2m.megaport.com/oauth2/token.
  • https://api-staging.megaport.com/: This is the test staging environment. You can test any action in this environment and the API calls and responses will mirror the production system, but the services won’t be deployed and you won’t be billed for any activity.
    • The token authentication URL for staging is https://oauth-m2m-staging.auth.ap-southeast-2.amazoncognito.com/oauth2/token.

3. Check the Auth Type

When retrieving the access token, ensure “Auth Type” is set to “Basic Auth”:

Auth Type

For additional API calls, the Auth Type should be set to “Bearer Token” and the token should be set to the access token variable {{accessToken}}.

Auth Type - Bearer Token

4. Use the correct API Key role

When creating the API Key and Secret you can choose the role, namely “Company Admin” or “Read Only”. Choosing the incorrect role can result in errors.

Ensure the correct role is chosen for the user.

API Key role

To improve security, it is also recommended that you add the API Client and Secret as a variable within the authorization section.

API Client and Secret variable

You can then add the details to just the collection under “Edit”.

Here, you need to remove the brackets:

API Key edits

6. Check MVE image details

As the Megaport MVE portfolio increases, the image ID can change over time. A common deployment error is to reuse an old image ID without confirming the latest image ID version, resulting in an error like this one:

{
   "message": "Validation failed",
   "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
   "data": "MVE product code null not found"
}

Before adding your image ID, ensure you have the latest one by https://api.megaport.com/v3/product/mve/images checking current image IDs for each vendor.

  "data": {
       "mveImages": [
           {
               "id": 63,
               "version": "vION 3108v-6.4.1",
               "product": "Prisma SD-WAN 3108v",
               "vendor": "Palo Alto",
               "vendorDescription": "Engineering Build - Not for Production Use",
               "releaseImage": false,
               "productCode": "prisma-3108"
           },
           {
               "id": 56,
               "version": "6.4.15",
               "product": "FortiGate-VM",
               "vendor": "Fortinet",
               "vendorDescription": null,
               "releaseImage": true,
               "productCode": "fortigate"
           },

7. Avoid overlapping IP addresses

When a VXC with a specific IP schema is deployed and the same API call is made, you will get an error as follows:

data": "VRouter: ipAddress '169.254.96.46/29' overlaps with '169.254.96.40/29', Validation of a_csp_request failed"

Duplicate IP addresses are not allowed. Likewise, no overlapping VLAN IDs are permitted per individual Megaport, MCR, or MVE. Remove these duplicates and overlaps to resolve the issue.

Remove IP overlaps

8. MVE and Azure inner VLAN tag statement

There are two ways to deploy an Azure ExpressRoute:

  1. As “Single Azure Peering VLAN” for customers that do not support Q-in-Q
  2. With Q-in-Q enabled.

Each deployment method has a slightly different tag statement, and it’s easy to confuse the two – but doing so will cause issues.

Confirm your ExpressRoute deployment method and follow the relevant steps:

1. Single Azure Peering VLAN: The A-End (Megaport) and B-End (Azure) will have the same VLAN ID. Megaport passes/translates the Azure inner VLAN (C-TAG) as defined in the ExpressRoute portal. In the example below it is 200:

Single Azure Peering VLAN

The associated API field is called “innerVlan” and relates to the C-TAG as defined in the Azure portal.

{% raw %}     "rateLimit": 1000,
     "term": 12,
     "aEnd": {
       "innerVlan": 200
     },
     "bEnd": {
       "productUid": "{{azurepuid}}",
       "innerVlan": 200{% endraw %}

2. Q-in-Q: Within the Azure portal the same inner VLAN (C-TAG) is configured, but now as Q-in-Q is enabled, the Azure VLAN is not exposed in the Megaport APIs.

In the example below, the “innerVlan” field is actually the outer VLAN or S-TAG. The naming convention is the same, which is what causes the confusion.

{% raw %}"rateLimit": 1000,
"term": 12,
"aEnd": \{
"innerVlan": 100
     },
     "bEnd": {
       "productUid": "{{azurepuid}}"{% endraw %}

9. Enter your diversity zone

The “diversityZone” field is optional, and if not requested then the diversity zone will be automatically added:

Diversity zone

Diversity zone 2

Not confirming the diversity zone required for your service, as well as the preferred deployment location, could result in an unsuccessful deployment.

To avoid this, navigate to your diversity zone field and ensure it’s set to the correct location.

10. Align the Megaport diversity zone to the CSP zone

Once your Megaport service has deployed into your chosen diversity zone and you then wish to deploy a VXC into a Cloud Service Provider (CSP), we recommend deploying the cloud VXC in the same diversity zone as your Megaport service. Failure to do this can result in possible single points of failure within your network.

To align your Megaport diversity zone and CSP zone, confirm the diversity zone as follows:

https://api.megaport.com/v2/dropdowns/partner/megaports?connectType={cloudProvider}&vxcPermitted={boolean}

The below example uses AWSHC (for AWS Hosted Connection), with results filtered by location.

“productUid” would be the B-nd location in the VXC order.

{
           "productUid": "dc745b48-6e84-4a84-9023-76f151c0b7d2",
           "companyUid": "605cb850-dfb4-4a05-a171-8bf17757b3a2",
           "companyName": "AWS",
           "title": "EU (Stockholm) (eu-north-1)",
           "locationId": 95,
           "speed": 10000,
           "maxVxcSpeed": 10000,
           "vxcPermitted": true,
           "diversityZone": "red",
           "rank": 700,
           "lag_id": 5,
           "lag_primary": true,
           "aggregation_id": 120069,
           "connectType": "AWSHC"
       },
       {
           "productUid": "36ec86b8-e4e1-479a-958c-15917949c761",
           "companyUid": "605cb850-dfb4-4a05-a171-8bf17757b3a2",
           "companyName": "AWS",
           "title": "EU (Stockholm) (eu-north-1)",
           "locationId": 95,
           "speed": 10000,
           "maxVxcSpeed": 10000,
           "vxcPermitted": true,
           "diversityZone": "blue",
           "rank": 701,
           "lag_id": 3,
           "lag_primary": true,
           "aggregation_id": 120072,
           "connectType": "AWSHC"
       },

11. Export user activity

Customers often ask us how they can export user activity. This is possible via the following GET API call:

https://api.megaport.com/v2/activity?personIdOrUid={personID}&companyIdOrUid={companyID}&page=0

Export user activity

Megaport’s new v3 APIs

Megaport is deprecating v2 APIs on 30 September 2024. Our new v3 API suite offers more features and functionalities – we think you’re going to love it. An FAQ detailing the API v2 shutdown is available here if you want to learn more.

Need help on something we didn’t cover in this blog? From live chat to extensive documentation, get the support you need here.

Related Posts

The Future of Cloud Gaming Infrastructure

The Future of Cloud Gaming Infrastructure

As the COVID-19 pandemic continues, more people are turning to cloud gaming—powered by cloud infrastructure—for entertainment. What does its future hold?

Read More
Sungard AS and Megaport: Solving the Cloud Connectivity Challenge

Sungard AS and Megaport: Solving the Cloud Connectivity Challenge

IT departments face the twin challenges of optimizing cloud use while managing the rising demands on application performance. A new partnership, which pairs Megaport’s Software-Defined Cloud Interconnection (SDCI) capabilities with Sungard AS’ data centers around the globe, now helps enterprises tackle both challenges.

Read More
Integrating Your Cloud Stack For Multicloud

Integrating Your Cloud Stack For Multicloud

Gartner® mentions that “by 2025, 35% of companies that use multiple cloud providers will use a single network stack, an increase of more than 10 times from 2021.” What does that mean for you?

Read More