Memsource Legacy API

File Data Type


Memsource Legacy API will be deprecated in September 2020. It is disabled for all new organization accounts created after May 7th 2019.
Please use Memsource REST API instead.

file's data type is used to post binary data into various API calls. Every API call that contains at least one argument of type file has to meet the following requirements:

  • HTTP POST method must be used
  • Multipart/form-data request as described in HTML specs must be formed


Java HttpClient Example

HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httpPost = new HttpPost(webServerUrl);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));
StringBody taskPart;
StringBody formatPart;
StringBody saveToTransMemoryPart;
StringBody setCompletedPart;
ByteArrayBody fileContentPart;
// ... fill variables with data ... //

reqEntity.addPart("task", taskPart);
reqEntity.addPart("format", formatPart);
reqEntity.addPart("saveToTransMemory", saveToTransMemoryPart);
reqEntity.addPart("setCompleted", setCompletedPart);
reqEntity.addPart("bilingualFile", fileContentPart);

C++ Qt Example

QHttpMultiPart* multiPartData = new QHttpMultiPart( QHttpMultiPart::FormDataType );
QBuffer* buffer = new QBuffer( multiPartData );
buffer->open( QIODevice::WriteOnly );
// ... fill buffer with data ... //
writer.writeTo( buffer );

QHttpPart filePart;
filePart.setHeader( QNetworkRequest::ContentTypeHeader, QVariant( "application/octet-stream" ) );
filePart.setHeader( QNetworkRequest::ContentDispositionHeader, QVariant( QString( "form-data; name=\"bilingualFile\"; filename=\"" ) + model->getFileInfos()[0].original + "\"" ) );
buffer->open( QIODevice::ReadOnly );
filePart.setBodyDevice( buffer );
multiPartData->append( filePart );
Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.



Article is closed for comments.