When using Anqi CMS for website content management, we often deal with various API interfaces, among whicharchive/listThe interface is the core to obtain the document list. During use, you may encounter interface returnscodeWith-1The situation. At this point, understandingmsgThe information provided by the field is particularly important, as it helps us quickly locate the problem.
Whenarchive/listInterface returnscode: -1This means that the request was not successful, and the specific cause of the failure will bemsgField details are described. The design philosophy of Anqi CMS is to use standardized error codes for some non-specific, flexible description errors, and use-1error codes throughmsgThe field provides a readable and understandable error cause.
Let's discuss some common error messages that the field may provide and their meanings when callingarchive/listthe interface,msgcommon error messages and their meanings that the field may provide:
CommonmsgError messages and scenarios
Missing parameters or incorrect formatThis is one of the most common error types.
archive/listThe interface provides a wealth of request parameters, but certain parameters are required in specific scenarios or have strict requirements for data format. If your request is missing necessary parameters or provides parameter values that do not comply with the specifications,msgThe field will prompt you."Missing required parameter: moduleId"or"缺少必要参数: moduleId"When you try to get the document list, especially when using the filter function or when you need to specify a model,moduleIdThe parameter is indispensable. If the parameter is not provided in the request or its value is empty, you may receive this error."Invalid category ID format"or"分类 ID 格式不正确":categoryIdThe parameter is used to specify the document category to be queried. If you providecategoryIdAn invalid integer (for example, entered letters or special characters) will be reported by the system."Module not found"or"未找到指定的文档模型": If you have providedmoduleIdBut if the document model corresponding to this ID does not exist in the Anqi CMS system or has been disabled, this kind of prompt will appear."Parameter 'limit' format error"or"limit 参数格式错误":limitThe parameter supports two forms: a single number (such aslimit="10")or two numbers separated by a comma,such aslimit="2,10")。IflimitThe value does not match one of these formats,such aslimit="abc"Orlimit="10,a",the system will prompt a format error。"Archive ID is required for related type"or"type=related 时文档 ID 必传": When you settype="related"When trying to obtain relevant documents, the system needs a basic documentidto determine the standard of 'relevant'. If at thisidthe parameters are missing or invalid, you will see this kind of error
No results found for data querySometimes, your request parameters are valid in themselves, but no data matching these conditions was found in the CMS system. Although this is not an error at the code level, it may also be encapsulated in business logic as
code: -1and passmsggive a clear explanation."No archives found matching the criteria"or"没有符合条件的文档": This usually happens when you have used overly strict filtering criteria (such as,categoryIdspecified an empty category, orqSearched for a non-existent keyword or custom filter parameters resulted in no matches), resulting in no documents being able to match your query request.
Other business logic restrictions or internal errorsIn addition to the above common situations,
code: -1It may also cover some other business logic restrictions, or in rare cases, indicate that an unexpected error has occurred within the system."Access denied"or"无权限访问": Although Anqi CMS provides specific error codes for unlogged/unauthorized situations,1001/1002it may also occur under certain data access or business logic restrictions, possibly-1combined with specificmsgRepresents."Internal server error"or"内部服务器错误"This type of error message is quite general, usually indicating that the server encountered an unhandled exception while processing your request.This may require checking the server logs or contacting the website administrator.
How to locate and solve problems
When you encountercode: -1The most critical first step when you respond is to read carefullymsgThe content of the field.
- Check request parametersAccording to
msgCheck the prompt, compare witharchive/listThe API documentation, check each request parameter you send. Confirm that all required parameters have been provided, and that the parameter types, formats, and value ranges meet the requirements. - Verify data validityIf you have used:
id/moduleIdorcategoryIdPlease ensure that the parameters are confirmed to exist and are valid in the AnQi CMS backend. For example, a category may have been deleted or set to hidden status. - Simplify the requestIf the error message is not clear enough, or you have multiple filtering conditions, you can try to simplify the request step by step. For example, use only
moduleIdGet the list first, confirm there are no problems, and then add graduallycategoryId/order/flagWait for parameters until the specific parameter causing the error is found. - Check the background log: For developers or website administrators, the backend log of Anqi CMS is a valuable resource for troubleshooting.Detailed stack trace information or more specific business logic errors, which are usually recorded in server logs.
By using the above methods, you can usually effectively locate and resolvearchive/listInterface returnscode: -1Problems encountered at the time, ensuring the normal display of website content.
Frequently Asked Questions (FAQ)
1. Why does Anqi CMS usecode: -1To represent errors, rather than defining a unique error code for each one?
Adopting AnQi CMScode: -1CombinemsgThe way of field is mainly to provide greater flexibility.Different errors may arise from a variety of complex situations, and if a unique error code is defined for each subtle error, the error code list will become very large and difficult to maintain.code: -1Indicates a "general error" status, then place the specific, readable error description inmsgIn the field, it not only makes it convenient for developers to quickly understand the problem, but also reduces the memory burden of error codes, making error handling more concise and efficient.
2.msgWill the field always provide detailed error information? IfmsgWhat should I do if the field is empty or the information is unclear?
In most cases, Anqi CMS will try tomsgProvide clear error messages. However, in some extreme or unexpected internal error scenarios,msgThe field may be quite general, even possibly empty (although this is rare). IfmsgInformation is unclear, please first check that all request parameters are in full compliance with the document requirements and try to simplify the request.If the problem still exists, the most effective way is to check the operation log of the security CMS server, as lower-level error information is usually recorded there.At the same time, you can also refer to the official documentation of Anqi CMS or seek community support.
3. Besidesarchive/listThe interface, other API interfaces of AnQi CMS will also return an error when an error occurscode: -1?
Yes, according to the Anqi CMS API documentation,code: -1As a general error code forarchive/detail,archive/publish,archive/filtersand this is common in most business interfaces. This means that when you are handling the Anqicms API response, you can follow the same error handling logic: first judgecodeIs it0(Successful), if not, then pay attentioncodeThe specific value (such as1001Not logged in,1002Not authorized), forcode: -1the situation, then further analysismsgfield to obtain detailed error reasons.