How do I fix the 'no implicit conversion of nil into String' error when creating a plan via API?
Context
Section titled “Context”You encounter errors like ‘no implicit conversion of nil into String’ or “undefined method `create_issue’ for nil” when creating a test plan and linking Jira issues via the Testomat.io Public API.
Answer
Section titled “Answer”These errors are due to an invalid request structure.
Error 1: “no implicit conversion of nil into String” when creating a plan
Section titled “Error 1: “no implicit conversion of nil into String” when creating a plan”- The request body format is invalid. Ensure the
typeandattributesstructure matches the expected API format. - Send a POST request to
https://app.testomat.io/api/{project_id}/planswith this body:{"data": {"type": "plans","attributes": {"title": "some title","kind": "manual","test-plan": "{\"tests\":[\"a760adbd\"]}"}}} - Important: Do not include
jira-issuesin this request. Jira issues must be linked separately.
Error 2: “undefined method `create_issue’ for nil” when linking Jira issues
Section titled “Error 2: “undefined method `create_issue’ for nil” when linking Jira issues”- This error usually indicates a missing or invalid parameter (
plan_id,jira_id,jiraproject_id), incorrectContent-Typeheader, or a deleted or unrelated plan.
- Confirm that the plan exists and belongs to the same project.
- Use the endpoint
POST https://app.testomat.io/api/{project_id}/jira/issues. - Send this request body:
{"jira_id": "EP-2515","plan_id": "71e04c51","jiraproject_id": "d40a638c"}
- Add the header
Content-Type: application/json. - Verify that
jira_idandjiraproject_idare valid and theplan_idis active and exists in the given project if the error persists.
- Use
"type": "plans"and valid attributes when creating a plan. - Attach Jira issues via the
/jira/issuesendpoint, never inside the plan-creation request. - Always include
Content-Type: application/jsonin the headers. - Ensure all IDs exist and belong to the same project.