REST API: POST to projects_projectid_test-sets_parameters

Wednesday, July 20, 2022

My issue is regarding a POST operation to the REST API:  projects\{project_id}\test-sets\parameters

I find it impossible to create a test-set level test-case-parameter by using this REST API POST. The documentation is very unclear, but one would assume that I don't have to provide a TestCaseParameterId in the POST body because I am creating a new entity and this identifier should be created for me.  I get an error like this every time. I am passing TestSetId (and the Id is good), Name, and Value, but not TestCaseParameterId.  If I am really supposed to pass a TestCaseParameterId how am I supposed to get one?  After all, the entire point of the call is to create a new TestCaseParameter (at the test-set level) right? So how do I know its ID before it exists?  And if you do intend to assign an ID for me, shouldn't this REST call return the newly created entity so that I can find out what it is?

Request Error       The server encountered an error processing the request. The exception message is 'Database foreign key violation occurred'. See server logs for more details. The exception stack trace is: at Inflectra.SpiraTest.Business.SpiraTestEntitiesEx.SaveChanges(SaveOptions options, Nullable`1 userId, Boolean updateHistory, Boolean sendNotification, Nullable`1 rollbackId)

Looking in the server logs as suggested turns up a little more detail:

Messages:Database foreign key violation occurred [APPLICATION.Business.EntityForeignKeyException]An error occurred while updating the entries. See the inner exception for details. [System.Data.UpdateException]The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TST_TEST_CASE_PARAMETER_TST_TEST_SET_PARAMETER". The conflict occurred in database "SpiraTeam", table "dbo.TST_TEST_CASE_PARAMETER", column 'TEST_CASE_PARAMETER_ID'.The statement has been terminated. [System.Data.SqlClient.SqlException]




1 Replies
Wednesday, July 20, 2022
re: bern_mccarty Wednesday, July 20, 2022

The error is because you are missing a value for:


This is the ID of the parameter as defined on the test case, not its instance on the test set (which is what you are creating).

You would get the value by first calling this function on a specific test case:

GET: projects/{project_id}/test-cases/{test_case_id}/parameters

  • Started: Wednesday, July 20, 2022
  • Last Reply: Wednesday, July 20, 2022
  • Replies: 1
  • Views: 80