Below are lists of REST API error codes, and an explanation of how errors are returned back to applications.
Handling and Logging Exceptions
When developing for Marketo, it’s very important that requests and responses get logged when an unexpected exception is encountered. While certain types of exceptions, such as expired authentication can be safely handled by reauthentication, others may require support interactions, and requests and responses will always be requested in this scenario.
The Marketo REST API can return three different types of errors under normal operation:
- HTTP-Level – These errors are indicated by a 4xx code.
- Response-Level – These errors are included in the “errors” array of the JSON response.
- Record-Level – These errors are included in the “result” array of the JSON response, and are indicated on an individual record basis with the “status” field and “reasons” array.
Under normal operating circumstances Marketo should only return two HTTP status code errors, 413 Request Entity Too Large, and 414 Request URI Too Long. These are both recoverable through catching the error, modifying the request and retrying, but with smart coding practices, you should never encounter these in the wild.
Marketo will return 413 if the Request Payload exceeds 1MB, or 10MB in the case of Import Lead. In most scenarios it unlikely to hit these limits, but adding a check to the size of the request and moving any records which cause the limit to be exceeded to a new request should prevent any circumstances which lead to this error being returned by any endpoints.
414 will be returned when the URI of a GET request exceeds 8KB. To avoid it, check against the length of your query string to see if it exceeds this limit. If it does change your request to a POST method, then input your query string as the request body with the additional parameter ‘_method=GET’. This forgoes the limitation on URIs. It’s rare to hit this limit in most cases, but is somewhat common when retrieving large batches of records with long individual filter values such as a GUID.
The Identity endpoint can return a 401 Unauthorized error. This is typically due to an invalid Client Id or invalid Client Secret.
Response level errors are present when the “success” parameter of the response is set to false, and will be structured like this:
Each object in the “errors” array has two members, “code,” which is a quoted integer from 600 to 799 and a “message” giving the plaintext reason for the error. 6xx codes always indicate that a request failed completely and were not executed. An example of this is a 601, “Access token invalid,” which is recoverable by re-authenticating and passing the new access token with the request. 7xx errors indicate that the request failed, either because no data was returned, or the request was incorrectly parameterized, such as including an invalid date, or missing a required parameter.
Response-Level Error Codes
|413||Request Entity Too Large||Payload exceeded 1MB limit.|
|414||Request-URI Too Long||URI of the request exceeded 8k. The request should be retried as a POST with param _method=GET in the URL, and the rest of the querystring in the body of the request.|
|502||Bad Gateway||The remote server returned an error. Likely a timeout. The request should be retried with exponential backoff.|
|600*||Empty access token||An Access Token parameter was not included in the request.|
|601*||Access token invalid||An Access Token parameter was included in the request, but the value was not a valid access token.|
|602*||Access token expired||The Access Token included in the call is no longer valid due to expiration.|
|603||Access denied||Authentication is successful but user doesn’t have sufficient permission to call this API. Additional permissions may need to be assigned to the user role.|
|604*||Request timed out||The request was running for too long (e.g. encountered database contention), or exceeded the time-out period specified in the header of the call.|
|605*||HTTP Method not supported||GET is not supported for Sync Leads endpoint, POST must be used.|
|606||Max rate limit ‘%s’ exceeded with in ‘%s’ secs||The number of calls in the past 20 seconds was greater than 100|
|607||Daily quota reached||Number of calls today exceeded the subscription’s quota (resets daily at 12:00AM CST).
Your quota can be found in your Admin->Web Services menu. You can increase your quota through your account manager.
|608*||API Temporarily Unavailable|
|609||Invalid JSON||The body included in the request is not valid JSON.|
|610||Requested resource not found||The URI in the call did not match a REST API resource type. This is often due to an incorrectly spelled or incorrectly formatted request URI|
|611*||System error||All unhandled exceptions|
|612||Invalid Content Type||If you see this error, add a content type header specifying JSON format to your request. For example, try using “content type: application/json”. Please see this StackOverflow question for more details.|
|613||Invalid Multipart Request||The multipart content of the POST was not formatted correctly|
|614||Invalid Subscription||The destination subscription cannot be found or is unreachable. This usually indicates temporary inaccessibility.|
|615||Concurrent access limit reached||At most 10 requests can be processed by any subscription at a time. This will be returned if there are already 10 requests for the subscription ongoing.|
|701||%s cannot be blank||The reported field must not be empty in the request|
|702||No data found for given search scenario||No records matched the given search parameters.
Note: Many failed search operations will return “success = true” and no errors and set a warnings informational string.
|703||Feature is not enabled for the subscription||A beta feature that has not been in enabled in a user’s subscription|
|704||Invalid date format||A date was specified that was not in the correct format|
|709||Business Rule Violation||The call cannot be fulfilled because it violates a requirement to create or update an asset, e.g. trying to create an email without a template. It is also possible to get this error when trying to:
|710||Parent Folder Not Found||The specified parent folder could not be found|
|711||Incompatible Folder Type||The specified folder was not of the correct type to fulfill the request|
|713||Transient Error||A system resource was temporarily unavailable at the time of the API call. When this error is encountered, it is advised to wait for a period of time and then retry the request.|
* An API call that returns this response code is not counted against your daily quota, or your rate limit
Record level errors indicate that an operation could not be completed for an individual record, but the request itself was valid. A response with record-level errors will follow this pattern:
"message":"Lead already exists"
Each record in a successful request may succeed or fail on an individual basis which is indicated by the status field of each record included in the result array of a response. The “status” field of these records will be “skipped” and a “reasons” array will be present. Each reason contains a “code” member, and a “message” member. The code will always be 1xxx, and the message will indicate why the record was skipped. An example would be where a Sync Leads request has “action” set to “createOnly” but a lead already exists for one of the keys in the submitted records. This case will return a code of 1005, and a message of “Lead already exists” as displayed above.
Record-Level Error Codes