Uploading screenshot to a Test Run using Java and Rest API

Tuesday, March 10, 2020


I am using Java and I am trying to upload .png file in request after converting it to Base64 encoded String as below:

File f1 = new File(filepath);

byte[] fileContent = FileUtils.readFileToByteArray(f1);String encodedString = Base64.getEncoder().encodeToString(fileContent);

In the request body, I am setting encodedString as value for BinaryData but I am receiving error as shown below. 

Can someone please help me in resolving this?


End points used: 

a) /projects/{project_id}/documents/file?filename={filename}&tags={tags}&folder_id={folder_id}&document_type_id={document_type_id}&artifact_type_id={artifact_type_id}&artifact_id={artifact_id}

b) /projects/{project_id}/documents/file


Error Returned by SpiraRest API:

 <p>The server encountered an error processing the request. The exception message is 'There was an error deserializing the object of type System.Byte[]. End element 'root' from namespace '' expected. Found element 'IsAttachments' from namespace ''.'. See server logs for more details. The exception stack trace is: </p>      <p>   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.ProcessMessage11(MessageRpc&amp; rpc)   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>

1 Replies
Tuesday, March 10, 2020
re: akathuria Tuesday, March 10, 2020


Can you please log a help desk ticket?



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


  • Started: Tuesday, March 10, 2020
  • Last Reply: Tuesday, March 10, 2020
  • Replies: 1
  • Views: 904