# Error Cases

The following sections highlight the most common scenarios in which Mobile Data
Plan Sharing API returns an error to the caller. If the errors persist, please
reach out to [mdp-support@google.com](mailto:mdp-support@google.com) for support and share the URL being called
along with the request body.

## HTTP 404 Not Found

The most common reason for an HTTP 404 error is when GTAF is unable to find the
GCM token of the user for whom a notification should be sent. This happens when
the device either did not get a chance or failed to register the CPID and the
associated GCM token with GTAF. This could also happen if the device is
registered with pre-prod instance of GTAF and the notification is being sent to
prod instance of GTAF.

To diagnose this error:

1. ensure that the MDP UI is successfully loading on the device.
2. ensure that path parameters and the query parameters in the call are URL encoded.
3. try both pre-prod (preprod-mobiledataplansharing.googleapis.com) and prod endpoints (mobiledataplansharing.googleapis.com).

## HTTP 400 Bad Request

This error happens when the body of the request sent to GTAF is invalid. The
most common scenarios for this are:

1. updateTime in [PlanStatus](https://developers.google.com/mobile-data-plan/reference/rest/v1/operators.planStatuses#PlanStatus) is not provided or is in the future.
2. expireTime in [PlanStatus](https://developers.google.com/mobile-data-plan/reference/rest/v1/operators.planStatuses#PlanStatus) is not provided or is in the past.
3. userKey query parameter is missing.
4. all the fields required for constructing a notification are not present. Please see [notification guidelines](https://developers.google.com/mobile-data-plan/notifications) for details on how to trigger notifications.

## HTTP 409 Conflict

GTAF returns this error to the caller if the
[PlanStatus](https://developers.google.com/mobile-data-plan/reference/rest/v1/operators.planStatuses#PlanStatus) in cache is
more recent (i.e., the updateTime is more recent) than the one being sent in the
request. Please check your logs to see if a
[PlanStatus](https://developers.google.com/mobile-data-plan/reference/rest/v1/operators.planStatuses#PlanStatus) has been
pushed for this user.

## HTTP 403 Forbidden

GTAF returns this error if the caller is not authorized to call Mobile Data Plan
Sharing API for the particular ASN being used in the URL. To diagnose this
error:

1. verify that the [API](https://console.cloud.google.com/apis/library/mobiledataplansharing.googleapis.com/) is enabled in Google cloud console [API
   Library](https://console.developers.google.com/apis/library).
2. the service account being used for the call has been added to the [ISP
   portal](https://isp.google.com) of the carrier.