API error FAQ

更新时间:
复制 MD 格式

This topic describes common error messages for the Content Moderation API.

For more FAQs about API calls, see Content Moderation API.

Why do I get a "You have not opened Yundun Content Moderation Service" error when I call an API?

Cause: Content Moderation is not activated.

Solution: Log on to the Content Moderation service activation page to activate the service before calling the API.

Why do I get an "SDK.ServerUnreachable: Specified endpoint or uri is not valid" error when I deploy to an ECS instance, even though local tests pass?

Cause: The ECS instance is not configured for public network access. You must access the Content Moderation API over the public network.

Solution: Configure public network access for the ECS instance. First, use the ping command to check the network connection to the endpoint of your environment. If the network is connected, check whether the required dependencies for your programming language are missing or if you are using an outdated version of aliyun-**-sdk-core. Use the code samples in the SDK documentation. For more information, see SDK overview.

Why do I get an "SDK.ServerUnreachable : SocketTimeoutException has occurred on a socket read or accept" error when I use the Content Moderation SDK?

Cause: A network access error occurred. You must access the Content Moderation API over the public network.

Solution: Configure public network access for your ECS instance. Verify your network environment by pinging the corresponding endpoint. If the network is connected, check whether the required dependencies for your programming language are missing or if you are using an outdated version of aliyun-**-sdk-core. Use the code samples in the SDK documentation. For more information, see SDK overview.

Why do I get an "algo failed(ocridcard-modelnotexist)" error when I call an API?

Cause: The region associated with the endpoint you are using does not support the OCR ID card model (ocridcard-model).

Solution: Select an endpoint in a region that supports this feature. For more information, see Endpoints.

Why do I get a "Your using subaccount is not authorized, please refer to the page" error when I call an API?

Cause: The RAM user is not authorized.

Solution: To call the Content Moderation API as a RAM user, you must first create the user and grant the necessary permissions. For more information, see Use a RAM user to call the Content Moderation API.

Why do I get a 401 (NOT_ALLOWED) error when I call an API?

Cause: This error typically occurs when you use an insecure URL for an image, video, or audio file.

Solution: Check whether your URL is secure. Also, verify that your IP address is not in one of the following private network ranges. Content Moderation requires a public IP address.

  • 10.0.0.0/8

  • 11.0.XX.XX/8

  • 100.64.0.0/10

  • 172.16.0.0/12

  • 192.168.0.0/16

  • 127.0.0.1/32

  • 33.0.XX.XX/8

Why do I get a 400 (BAD_REQUEST) error when I call an API?

Cause: This error usually indicates incorrect request parameters. If the error message is [task.url] is bad format, the URL is invalid.

Solution: Check that the API parameters are specified correctly. If the error indicates an invalid URL, check the URL. If the URL can be opened in a browser, check for special characters that may require URL encoding. For more information, see Common parameters.

Why do I get a 400 (service is invalid) error when I call the TextModeration API?

Cause: You passed an invalid value for the Service parameter in the TextModeration API call. The API did not recognize the service name.

Solution: Change the value of the Service parameter to a valid one. The TextModeration API supports the following values for the Service parameter:

  • comment_detection: Moderates comments.

  • chat_detection: Moderates chat messages.

  • pgc_detection: Moderates professionally generated content (PGC).

  • nickname_detection: Moderates nicknames.

  • ad_compliance_detection: Checks for advertisement compliance.

If you use a valid service name but receive a 408 (commodity not activated) error, the service name is correct but the service has not been activated. Go to the Content Moderation console to activate the required service. For more information, see Synchronous text scan.

Why do I get a 594 (EXPIRED) error when I call an API?

Cause: The task ID has expired. For example, when you query the results of an asynchronous image scan, the task ID is valid for only 24 hours. If you query a task that is older than 24 hours, the API returns an EXPIRED error.

Solution: After you submit an asynchronous scan task, poll for the results every 30 seconds to ensure you retrieve them before the task ID expires.

Why do I get a 596 (PERMISSION_DENY) error when I call an API?

Cause: This error can be caused by an unauthorized account, an account with an overdue payment, a service that is not activated, or a disabled account. Refer to the specific error message for details.

Solution: Check if the calling account is authorized or has an overdue payment. If you are using a RAM user, you must grant the RAM user the necessary permissions. If you have not activated Content Moderation, log on to the Content Moderation service activation page to activate the service first. For more information, see Use a RAM user to call the Content Moderation API.

Why do I get an "AlgorithmTimeOut" error or incomplete text results when I use a synchronous OCR scan?

Cause: The AlgorithmTimeOut error indicates that the scan timed out. OCR text recognition is a time-consuming process. The system sets a default timeout of 3 seconds for synchronous calls. If an image contains a large amount of text, the probability of a timeout increases.

Solution: If you scan images with a large amount of text, use the asynchronous OCR text recognition API (asynchronous scan). The system increases the number of retries and performs additional optimizations to prevent timeouts.

Why do I get a 592 (DOWNLOAD_TIMEOUT) error when I call an API?

Cause: The content download timed out. The download time limit is 3 seconds. Ensure the content size is within the API limits.

Solution: Check whether the image URL is accessible and whether the image can be downloaded within 3 seconds. If you use a CDN URL for the image, a timeout may occur due to a slow origin fetch. We recommend that you do not use CDN URLs. Cross-region access, such as requesting an Object Storage Service (OSS) object in a US region from a service in Singapore, is also likely to time out. Use an OSS address within the same region as the service.

Why do I get a "[task.dataId] is too long(>256)" error when I call the text moderation API?

Cause: The DataId exceeds 256 characters. DataId is a unique identifier for your business data and can consist of uppercase and lowercase letters, digits, underscores (_), hyphens (-), and periods (.). For example, a valid DataId is cfd33235-71a4-468b-8137-a5ffe323a7e8.

Solution: Adjust the DataId parameter according to the API documentation. For more information, see Synchronous text scan.

Why do I get a "Status Code: 400" error related to an incorrect signature when calling an API over HTTP?

Cause: The signature mechanism for HTTP calls is complex. If you build the signing method yourself, you may introduce code errors.

Solution: We recommend that you use the Content Moderation SDKs. The SDKs handle the signing process automatically, eliminating the need to write signing code. If you must use HTTP to call the API, review the signature mechanism first. For more information, see SDK overview and Request signature.

Why do I still get a 403 (Forbidden) error when using OSS violation detection after adding *.aliyuncs.com to the referer whitelist?

Cause: You do not have permissions to access the Object Storage Service (OSS) bucket.

Solution: Only users who have activated Object Storage Service (OSS) can use the OSS violation detection feature. Before you use this feature, you must grant Content Moderation the required permissions to access your OSS buckets. For more information, see Authorize Content Moderation to access OSS buckets.

Why do I get a 480 (DOWNLOAD_FAILED) error when I call an API?

Cause: The content download failed. This may be because the URL of the content to be scanned is inaccessible, or the content size or resolution exceeds the limits.

Solution: If you are scanning an image, confirm that the image URL is accessible. If you are using video snapshot, some images in the snapshot sequence may fail to download. Check the snapshot-related parameters, such as the time parameter. If you are scanning a video stream, confirm that the stream is being pushed during the scan.

Why do some URLs consistently return a 480 error when I call the synchronous video scan API?

Cause: The content download failed. This may be because the URL of the content to be scanned is inaccessible, or the content size or resolution exceeds the limits.

Solution: If you are using video snapshot, some images in the snapshot sequence may fail to download. Check the snapshot-related parameters, such as the time parameter. If the issue persists, contact us through online service. For more information, see Video snapshots.

Why do I get a 480 (GIF_TOO_MUCH_PIXELS) error when I call the image moderation API?

Cause: The download failed. The GIF_TOO_MUCH_PIXELS error message indicates that the content size or resolution exceeds the limits.

Solution: Image moderation supports images up to 20 MB in size, with a maximum height or width of 30,000 pixels (px), and a total resolution not exceeding 250 million. If an image exceeds these limits, compress it before submitting it for scanning. For more information, see Synchronous scan.

Why do I get a 480 (Input/output error) when I call the live video stream moderation API?

Cause: The download failed. The Input/output error message is usually related to streaming media file issues, such as an inaccessible or undownloadable URL.

Solution: If you are scanning a video stream, confirm that the stream is being pushed and that the live broadcast has not stopped. If you are using video snapshot, some images in the snapshot sequence may fail to download. Check the snapshot-related parameters, such as the time parameter.

Why do I get a 500 (GENERAL_ERROR) error when I call an API?

Cause: This is usually a temporary server-side error. The specific cause must be identified from the returned error message.

Solution: If this is an occasional error, retry the request. If the error persists, contact online service with the detailed error message for investigation.

Why do I get a 500 (service interrupted) error when I use the Content Moderation SDK?

Cause: This is usually a temporary server-side error. The service interrupted message may indicate an incompatibility between the SDK version you are using and the server.

Solution: Ensure you are using the latest SDK version. If not, upgrade it. For more information, see Installation.

Why do I get a 500 (failed to convert to pcm) error when I call the audio moderation API?

Cause: This is usually a temporary server-side error. The failed to convert to pcm message may be caused by a failure in audio stream transcoding or fetching.

Solution: Check if the audio stream is being pushed correctly. You can use tools like FFMPEG to test audio stream encoding and decoding. Supported audio stream protocols include HTTP, RTMP, and RTSP. For more information, see Asynchronous audio scan.

Why do I get a 586 (ALGO_FAILED) error when I call the Content Moderation API?

Cause: An algorithm service error occurred. This is typically caused by a timeout due to network jitter in the algorithm service.

Solution: If this is an occasional error, retry the request. If the error persists, contact online service for investigation.

Why do I get a 588 (EXCEED_QUOTA) error when I call the Content Moderation API?

Cause: The request rate exceeds the concurrency quota. The default concurrency quotas are: 50 images/second for image scan, 20 streams/second for video scan, 20 streams/second for audio scan, 100 entries/second for text scan, and 10 images/second for image OCR.

Solution: Reduce your request frequency and queue content for scanning. Alternatively, estimate your peak concurrency and contact your account manager to request an increase in your quota.

Why do I get a 586 error when I call the image detection API?

Cause: An algorithm service error occurred. If the error only occurs for specific images or videos, it might be due to an encoding or decoding failure.

Solution: Check if the image or video file is corrupted. You can also use a codec tool to test if the image or video can be properly decoded. Supported image formats include PNG, JPG, JPEG, BMP, GIF, and WEBP. For more information, see Synchronous scan.

Why do I get an "InvalidTimeStamp.Expired" error when I call the Content Moderation API?

Cause: The timestamp for the API call has expired. This error occurs if the client and server timestamps differ by more than 15 minutes.

Solution: Check if your server time has changed recently or if the client machine's time zone is configured correctly. For more information, see Common parameters.

Why does the audit feature in the console report an error after a long period of inactivity?

Cause: This error can occur if your login session has expired, leading to an authorization failure.

Solution: If the error includes a RequestId, try refreshing your browser and logging in to the console again. If the error persists, contact online service with the specific error message or a screenshot for investigation.

Why is no data returned when I use the Content Moderation text API SDK to scan a string that contains HTML tags?

Cause: If the string to be scanned contains HTML or other code tags, a firewall might interpret it as a risky code injection attempt and block the network request, resulting in no response.

Solution: Before you send text for scanning, filter out web code tags, such as HTML or SQL characters, to prevent a firewall from blocking the request. For more information, see Synchronous text scan.

Why do I get a "Specified time stamp or date value is expired" error when I call the OCR API before 09:00 or after 21:00?

Cause: The timestamp for the API call has expired. This error occurs if the difference between the client's timestamp and the server's timestamp exceeds 15 minutes.

Solution: Use the official SDKs (available for Java, Python, PHP, and other languages) to make API calls. If you must use HTTP, check if the server time has been changed recently or if the client machine's time zone is configured correctly. For more information, see Common parameters.

Why do I get a 403 error when calling the image moderation API after I set the OSS referer whitelist to http://*.aliyuncs.com and grant the AliyunOSSReadOnlyAccess permission?

Cause: To use the Content Moderation API to moderate images or videos stored in Object Storage Service (OSS), you must use publicly accessible OSS URLs.

Solution: Generate a temporary, publicly accessible URL for the object and then call the Content Moderation API. Accessing objects by using OSS authorization is not supported. If you cannot generate a public URL, use the OSS violation detection feature. This feature allows you to moderate objects once you grant Content Moderation permissions to access your OSS buckets. For more information, see OSS violation detection.

Why do I get a 406 error when I call the Content Moderation API?

Cause: This can be caused by an SDK version mismatch, such as using code from a newer SDK version with an older SDK library.

Solution: Ensure you are using the latest SDK version. If you use the Java SDK, upgrade both the Core and Green packages to the latest versions. Content Moderation provides SDKs for Java, Python, PHP, and other languages. For more information, see SDK overview.

Why do I get the error "The API is invalid" when I call an API to manage custom text library configurations?

Cause: Configuration management APIs, such as those for custom text libraries, support only the China (Shanghai) endpoint and do not support the China (Beijing) endpoint. This request fetches a list of text libraries. If you have not created any text libraries, the API does not return data.

Solution: Use the China (Shanghai) endpoint for management APIs. For more information, see Create a custom text library.

Why do I get a "UnicodeEncodeError" when running the Content Moderation Python SDK in a Jupyter Notebook or from the command line?

Cause: A UnicodeEncodeError is an IDE-related error. You need to check your IDE's environment settings for the root cause.

Solution: Run the Python SDK in a mainstream IDE, such as PyCharm. Since IDE-related issues depend on the specific environment, you must troubleshoot the issue yourself.