AnQi CMS document detail interface returncode: -1Troubleshooting Guide at the Time

When using AnQiCMS for website content management, we often use the provided API interface to retrieve or manipulate data. When calling the document detail interface (for example/api/archive/detail)when, if the received return result iscodethe field is-1This usually means that the request was not successful, and an error occurred during the server-side processing.Many users may feel confused when facing such a situation, not knowing where the problem lies.msgfield.

code: -1The occurrence is not just a generic 'server error' prompt. It is more like a signal, indicating that the specific details of the problem are hidden in the accompanying text.msgThis is in the field description of the error.msgThe field carries the error information returned by the backend system, which is usually human-readable and can greatly help us accurately locate the problem rather than guessing aimlessly.

msgField: The Key to Troubleshooting

Imagine that you are trying toidorfilenameto get the detailed content of a document, but the API returned{"code": -1, "msg": "文档ID或URL别名缺失"}. At this point,msgThe field explicitly points out the problem: your request is missing the requiredidorfilenameparameters. If the response is{"code": -1, "msg": "文档不存在"}Then you know that the requested document ID or alias does not have a corresponding record in the database.

This detailed error description greatly improves the efficiency of troubleshooting.It refines a vague 'error' into specific 'missing parameter', 'resource not found', or 'incorrect data format', etc., allowing us to directly check the root cause of the problem.

Commoncode: -1Scenarios andmsgGuidance

In the various interfaces of Anqi CMS,code: -1is a general error code, andmsgThe content of the field will vary according to specific business logic and error types. The following are some situations you may encounter when using the document details interface (or similar interfaces) andmsgField may provide help:

  1. Parameter error or missing:

    • msgMay display:“Document ID or URL alias missing”, “Parameter ID format is incorrect”, “Missing required parameter: id”
    • Troubleshooting direction: This is usually the most common question. Check if all required parameters (such asarchiveDetailthe interface requiresidorfilename) are included in your API request, and the types of these parameters (such asidIs it an integer? Does the format comply with the requirements of the API document?
  2. The requested resource does not exist:

    • msgMay display:"Document does not exist", "Category does not exist", "Model does not exist"
    • Troubleshooting direction: This means the document, category, or model you are trying to access does not have a corresponding record in the system. You need to verify the information you provided.idorfilenameIs correct, make sure it points to actual existing content.
  3. Data validation failed:This situation is more common when submitting data through interfaces such asarchivePublishIt is more common when submitting documents, but it may also occur in other interfaces, such as when invalid filter conditions are provided during search)

    • msgMay display:Title cannot be empty, Invalid category ID, Custom field [XXX] value does not meet the requirements
    • Troubleshooting direction: Check if the data you submitted conforms to business rules or field definitions. For example, when publishing documents, the title is usually a required field, and the category ID must be an existing valid category in the system.
  4. Business logic error:

    • msgMay display:You do not have access to this document, The document price is 0, no payment is required, The order has been canceled
    • Troubleshooting direction: This error indicates that the request is legal, but it cannot be completed due to certain business rules (such as permission restrictions, status mismatches, etc.).You need to check the current user's permissions, or request whether the object's status meets the operation conditions.
  5. System internal exception:

    • msgMay display:Database query failed, System internal error, please try again later, Unknown error, please contact the administrator
    • Troubleshooting direction: WhenmsgThis may mean that the backend server encountered unexpected technical issues when processing the request, when the system prompts internal errors.You can try to resubmit the request at this time. If the problem persists, you may need to check the server logs of AnQiCMS for more detailed technical stack information, or directly contact the AnQiCMS technical support team for assistance.

Actual operation suggestions

When you encountercode: -1be sure to develop the habit of checking firstmsgThe habit of fields. It usually gives you the most direct guidance.

  • Read carefullymsg:It is the first step in solving problems. Many times, the cause of the error is clear at a glance.
  • Refer to the API documentation:Please double-check the request parameters, return parameter definitions, and any specific instructions or notes for the interface you are calling. Ensure that all parameters comply with the specifications.
  • Check the request data:Confirm that the data you sent is complete, whether the format is correct, and whether the values are valid.
  • Use the developer tools:Developers can use browser tools or API client tools (such as Postman, Insomnia) to fully view the details of API requests and responses, including HTTP status codes, request headers, and response bodies, which is very helpful for troubleshooting network issues or request structure problems.
  • Step-by-step debugging:If the problem is complex, you can try to simplify the request, or make gradual modifications based on a known correct request to isolate the problem.
  • Keep the error information:If you need to seek help from others (such as AnQiCMS official support), please make sure to provide a completecodeandmsgInformation, as well as the request parameters and request address you send, will greatly speed up the problem-solving speed.

By fully utilizingmsgThe information provided by the field allows us to diagnose and resolve various issues with the AnQiCMS interface calls more effectively, ensuring the smooth operation of the website content.


Common Questions (FAQ)

Q1:code: -1andcode: 0What is the essential difference?

A1:code: 0Indicates that the interface request was successful, the server has processed the request as expected, and it usually willdatareturn the requested business data in the field.code: -1It indicates that although the API request may have reached the server, an error occurred in the business logic process of handling the request on the server side, resulting in the request not being completed successfully. The specific failure reason will be inmsgField detailed description.

Q2: Ifcode: -1it returned, butmsgthe field is empty, what should I do?

A2: According to AnQiCMS API specification,coderesponse for-1whenmsgThe field usually contains the error reason