The current API documentation for the Knowledge Base Answers endpoint (/api/v1/knowledge_bases/{ID}/answers/{ID}) is misleading regarding the method for retrieving the actual content (body) of an answer.
The documentation currently states:
If you want to get the content of an answer, add the parameters ?full=1&include_contents=1 to the query URL.
|
.. tip:: If you want to get the content of an answer, add the parameters |
Following this instruction does not result in the answer's body being included in the API response. Based on a review of the Zammad source code, the correct method is different from what is described.
Issue Details:
- The
full=1 parameter does not appear to be used by this endpoint for including the answer's body content.
- The
include_contents parameter does not accept a boolean 1. It requires the specific content_id associated with the answer's translation.
Correct Procedure to Retrieve Answer Content:
As our KB only uses English, I've found the content translation IDs correspond with the answer IDs exactly. Therefore, I am able to simply repeat the answer ID as the include_contents value.
To correctly fetch the answer content in general though, a two-step process is required:
- First Request: Make a GET request to
/api/v1/knowledge_bases/{ID}/answers/{answer_id}. The response will contain an assets object, and within it, a KnowledgeBaseAnswerTranslation object that includes the content_id.
- Second Request: Make a second GET request to the same endpoint, but this time, include the
content_id retrieved from the first call in the include_contents parameter, like so: ?include_contents={content_id}.
The response to this second request will then correctly include the KnowledgeBaseAnswerTranslationContent object, which contains the body of the answer.
The current API documentation for the Knowledge Base Answers endpoint (
/api/v1/knowledge_bases/{ID}/answers/{ID}) is misleading regarding the method for retrieving the actual content (body) of an answer.The documentation currently states:
zammad-documentation/api/knowledgebase/answers.rst
Line 11 in cc48967
Following this instruction does not result in the answer's
bodybeing included in the API response. Based on a review of the Zammad source code, the correct method is different from what is described.Issue Details:
full=1parameter does not appear to be used by this endpoint for including the answer's body content.include_contentsparameter does not accept a boolean1. It requires the specificcontent_idassociated with the answer's translation.Correct Procedure to Retrieve Answer Content:
As our KB only uses English, I've found the content translation IDs correspond with the answer IDs exactly. Therefore, I am able to simply repeat the answer ID as the
include_contentsvalue.To correctly fetch the answer content in general though, a two-step process is required:
/api/v1/knowledge_bases/{ID}/answers/{answer_id}. The response will contain anassetsobject, and within it, aKnowledgeBaseAnswerTranslationobject that includes thecontent_id.content_idretrieved from the first call in theinclude_contentsparameter, like so:?include_contents={content_id}.The response to this second request will then correctly include the
KnowledgeBaseAnswerTranslationContentobject, which contains thebodyof the answer.