<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom"><channel><title>Inflectra Customer Forums: Database foreign key violation error via REST API (Thread)</title><description> When using the REST API to create a Test Case in a Project, I get back a general 400 Bad Request error with the message  The server encountered an error processing the request. The exception message is Database foreign key violation occurred. See server logs for more details  in the response body, followed by some information about an exception stack trace  The JSON Im supplying in the body of the POST request is:  {Name:This is a the Test Case, TestCaseStatusId:0, TestCaseTypeId:0}  Ive also tried supplying the Name field only, and get the same error.  If I use the web interface to create a Test Case, I have no problems using the REST API to GET its ID number and then using POST to create Steps inside it, so I cant see what is stopping me from creating Test Cases. </description><language>en-US</language><copyright>(C) Copyright 2006-2026 Inflectra Corporation.</copyright><managingEditor>support@inflectra.com</managingEditor><category domain="http://www.dmoz.org">/Computers/Software/Project_Management/</category><category domain="http://www.dmoz.org">/Computers/Software/Quality_Assurance/</category><generator>KronoDesk</generator><a10:contributor><a10:email>support@inflectra.com</a10:email></a10:contributor><a10:id>http://www.inflectra.com/kronodesk/forums/threads</a10:id><ttl>120</ttl><link>/Support/Forum/spiratest/issues-questions/1969.aspx</link><item><guid isPermaLink="false">threadId=1969</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><category domain="http://www.inflectra.com/kronodesk/thread/tag">rest api error</category><title>Database foreign key violation error via REST API</title><description> When using the REST API to create a Test Case in a Project, I get back a general 400 Bad Request error with the message  The server encountered an error processing the request. The exception message is Database foreign key violation occurred. See server logs for more details  in the response body, followed by some information about an exception stack trace  The JSON Im supplying in the body of the POST request is:  {Name:This is a the Test Case, TestCaseStatusId:0, TestCaseTypeId:0}  Ive also tried supplying the Name field only, and get the same error.  If I use the web interface to create a Test Case, I have no problems using the REST API to GET its ID number and then using POST to create Steps inside it, so I cant see what is stopping me from creating Test Cases. </description><pubDate>Mon, 14 Jan 2019 22:03:47 -0500</pubDate><a10:updated>2019-01-30T04:01:08-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx</link></item><item><guid isPermaLink="false">messageId=3494</guid><author>David J (adam.sandman+support@inflectra.com)</author><title> Hello,  Most likely you need to pass additional information required by the API.  There is no such </title><description> Hello,  Most likely you need to pass additional information required by the API.  There is no such test case status as ID = 0 or type = 0, that is probably causing the issue right there.  Regards  Adam </description><pubDate>Wed, 16 Jan 2019 17:15:46 -0500</pubDate><a10:updated>2019-01-16T17:15:46-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3494</link></item><item><guid isPermaLink="false">messageId=3495</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><title> Hello Adam  The  SpiraTeam REST API 5.0 reference page for Test Cases  says those two properties de</title><description> Hello Adam  The  SpiraTeam REST API 5.0 reference page for Test Cases  says those two properties definitely exist and you definitely can pass the value 0:  TestCaseTypeId  - The type of test case, pass 0 to use the default value  TestCaseStatusId  - The status of the test case, pass 0 to use the default value     That documentation page also says Creates a new test case in the system. Name, TestCaseStatusId, and TestCaseTypeId are required fields. and even demonstrates the usage of those two fields in the JSON sample.    Also, as I said, even if I pass only the Name property, I still get the error.  If a required property is not passed in the request body, the API will normally send back a message advising which property has been omitted. So why in this case doesnt it tell me what Ive omitted?   Can you be more specific and tell me what additional information is required by the API, as all the criteria specified on the API documentation page seems to have been met. Alternatively, please post a sample JSON formatted body request that youve tested and works. </description><pubDate>Wed, 16 Jan 2019 21:26:56 -0500</pubDate><a10:updated>2019-01-16T21:26:56-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3495</link></item><item><guid isPermaLink="false">messageId=3496</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><title> Hello Adam  Ive just made a minor breakthrough.  I tried submitting the request to the SpiraTeam v4</title><description> Hello Adam  Ive just made a minor breakthrough.  I tried submitting the request to the SpiraTeam v4 REST API as per  this V4 REST API documentation page , and using just the Name field only, and it worked.... the Test Case was created.  When I inspect the Test Cases via the web interface, the Status shows as Obsolete and the Type as Functional, but all else is fine.  So, it seems like the v5 REST API has a bug or the documentation page is incorrect. </description><pubDate>Wed, 16 Jan 2019 21:50:37 -0500</pubDate><a10:updated>2019-01-16T21:50:37-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3496</link></item><item><guid isPermaLink="false">messageId=3497</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><title> Hello Adam  Ive just done some further tests and can use the v5 API to create a Project, then creat</title><description> Hello Adam  Ive just done some further tests and can use the v5 API to create a Project, then create a Test Case Folder. I then switch to the v4 REST API and create the Test Case. I then switch back to the v5 API and create the Test Steps within that Test Case.  This works around the bug in the v5 API for the Test Cases, but there is a limit of the v4 API in that it doesnt support the creation Test Cases inside Test Case Folders. Bummer!  Please let me know when your developers have had a closer look into the v5 bug that affecting the creation of Test Cases. </description><pubDate>Wed, 16 Jan 2019 22:40:41 -0500</pubDate><a10:updated>2019-01-16T22:40:41-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3497</link></item><item><guid isPermaLink="false">messageId=3498</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><title> Ive noticed that the v4 API does support creating Test Cases inside a Folder, the URL just needs to</title><description> Ive noticed that the v4 API does support creating Test Cases inside a Folder, the URL just needs to be different. So, I now have a full workaround for the v5 API bug until it can be resolved. </description><pubDate>Wed, 16 Jan 2019 22:52:56 -0500</pubDate><a10:updated>2019-01-16T22:52:56-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3498</link></item><item><guid isPermaLink="false">messageId=3510</guid><author>David Bakkers (david.bakkers@dimensiondata.com)</author><title> For anyone reading this thread, the issue turned out to be the API documentation, which says that t</title><description> For anyone reading this thread, the issue turned out to be the API documentation, which says that the two fields TestCaseStatusId and TestCaseTypeId can be set to a value of 0.  Those fields need to be set to a value of 1, or higher, where the number correlates to the position of the required value in the drop-down selection on the web interface, as per this example for the Status of a Test Case:    </description><pubDate>Wed, 30 Jan 2019 04:01:08 -0500</pubDate><a10:updated>2019-01-30T04:01:08-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1969.aspx#reply3510</link></item></channel></rss>