REST API creating test sets

Thursday, January 21, 2016
Avatar

Hello, 

I'm a novice user of SpiraTeam as my organization have selected it as our main tool for requirements / test case generation.  I've begun looking at the available REST API and am attempting to utilize it to create a simple test set.  I'm a bit confused with all the elements in the request payload and would hope to get some guidance and clarity. 

I'm specifically looking at:  POST: projects/{project_id}/test-sets?parent_test_set_folder_id={parent_test_set_folder_id}

I've tried the following POST Request: 

http://hostname/SpiraTeam/Services/v4_0/RestService.svc/projects/284/test-sets?parent_test_set_folder_id=13242

Headers:
Cache-Control: no-cache
username: johndoe
api-key: {187FC923-CE4F-4FCA-BEF0-73D7A37055F2}
Accept: application/json
Content-Type: application/json

Post Body:
{"ArtifactTypeId": 8,
"ConcurrencyDate": "/Date(1432130443523-0700)/",
"CustomProperties": [0],
"ProjectId": 284,
"AutomationHostId": null,
"CountBlocked": 0,
"CountCaution": 0,
"CountFailed": 0,
"CountNotApplicable": 0,
"CountNotRun": 0,
"CountPassed": 0,
"CreationDate": "/Date(1432130413227-0700)/",
"CreatorId": 968,
"CreatorName": "John Doe",
"Description": null,
"ExecutionDate": null,
"Folder": false,
"IndentLevel": "AAJAAAs",
"LastUpdateDate": "/Date(1432130443523-0700)/",
"Name": "RESTAPI",
"OwnerId": null,
"OwnerName": null,
"PlannedDate": null,
"ProjectName": "Test Project",
"RecurrenceId": null,
"RecurrenceName": null,
"ReleaseId": null,
"ReleaseVersionNumber": null,
"TestRunTypeId": null,
"TestSetId": null,
"TestSetStatusId": 3,
"TestSetStatusName": "Completed"}


What is a valid request body?  I'm receiving the following error.  Any help pointing me in the right direction would be greatly appreciated.  I don't have access to the server logs so I can not view more details to see where the issue is.

      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. The exception message is 'Expecting state 'Element'.. Encountered 'Text'  with name '', namespace ''. '. See server logs for more details. The exception stack trace is: </p>
      <p>   at System.Runtime.Serialization.XmlObjectSerializerReadContext.HandleMemberNotFound(XmlReaderDelegator xmlReader, ExtensionDataObject extensionData, Int32 memberIndex)
   at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.GetJsonMemberIndex(XmlReaderDelegator xmlReader, XmlDictionaryString[] memberNames, Int32 memberIndex, ExtensionDataObject extensionData)
   at ReadRemoteArtifactCustomPropertyFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
   at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
   at ReadArrayOfRemoteArtifactCustomPropertyFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
   at System.Runtime.Serialization.Json.JsonCollectionDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
   at ReadRemoteTestSetFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
   at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
   at System.ServiceModel.Dispatcher.SingleBodyParameterDataContractMessageFormatter.ReadObject(Message message)
   at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>

2 Replies
Monday, January 25, 2016
Avatar
re: dkwang Thursday, January 21, 2016
Hi Damon

I would trim down the REST body to only have the fields that are needed, some of them are read-only and others are NULL can be omitted:

{"CreationDate": "/Date(1432130413227-0700)/",
"CreatorId": 968,
"LastUpdateDate": "/Date(1432130443523-0700)/",
"Name": "RESTAPI",
"TestSetStatusId": 3}

If that doesn't work, please send us a help desk ticket and we can debug for you.

Regards

Adam
Monday, January 25, 2016
Avatar
re: inflectra.david Monday, January 25, 2016
Hello Adam,

Thank You for your suggestion.  I've stripped down the payload and it appears to be working for me.   Your response is much appreciated.

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Thursday, January 21, 2016
  • Last Reply: Monday, January 25, 2016
  • Replies: 2
  • Views: 9172