Thread

Skip Navigation LinksForums > SpiraTeam Forums > SpiraTeam Issues & Questi... > REST API creating test se...

REST API creating test sets RSS Feed

Wednesday, January 20, 2016

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
Adam SAdam S
re: D W on Wednesday, January 20, 2016
Monday, January 25, 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
D WD W
re: Adam S on Monday, January 25, 2016
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.
Tagged
Statistics
  • Started: 1/20/2016
  • Last Reply: 1/25/2016
  • Replies: 2
  • Views: 261
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.