Rest api to create project

Thursday, July 21, 2016 12:31:46 AM
when I use rest api to create project

url: http://localhost/SpiraTest/Services/v4_0/RestService.svc/projects
headers: 
{
Content-Type : application/json
accept:  application/json
username: bbbb8264
api-key: {992790F0-EDB3-46AE-879D-6884D82A0E49}
}

but get error message:

The server encountered an error processing the request. The exception message is 'Object reference not set to an instance of an object.'. See server logs for more details. The exception stack trace is:

at Inflectra.SpiraTest.Web.Services.v4_0.RestService.Project_Create(RemoteProject remoteProject, String existing_project_id) at SyncInvokeProject_Create(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

How can I fix it? I'm sorry to post question for two times.

2 Replies
Thursday, July 21, 2016 3:31:27 PM
Avatar
re: bbbb8264 on Thursday, July 21, 2016 12:31:46 AM
Hi Woody

You need to actually POST a project definition in JSON. Something like:

{"Active":true,
"CreationDate":"\/Date(-62135578800000-0500)\/",
"Description":"The description of my project",
"Name":"My New Project"}

Regards

Jim.
Friday, July 22, 2016 2:32:58 AM
Avatar
re: inflectra.jimx on Thursday, July 21, 2016
The contents of json file can't be found in doc (http://www.inflectra.com/SpiraDemo/Services/v4_0/RestServiceOperation.aspx?uri=projects&method=GET).
However, You tell me and it finally worked.
Thanks a lot.
Statistics
  • Started: Thursday, July 21, 2016 12:31:46 AM
  • Last Reply: Friday, July 22, 2016 2:32:58 AM
  • Replies: 2
  • Views: 2354