Phrase TMS API


文本由 Phrase Language AI 从英语机器翻译而得。

文件 `%1`数据类型用于将二进制数据发布到各种 API 调用中。每个包含至少一个类型=""参数文件的 Api 调用必须至少满足以下要求:

  • 必须使用 HTTP 请求方法。

  • 必须形成HTML规范中描述的多部分/表格数据请求。


Java HttpClient

HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httpPost = new HttpPost(webServerUrl);
MultipartEntity requestEntity = 新建 MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName (“UTF-8”));
StringBody taskPart;
StringBody formatPart;
StringBody saveToTransMemoryPart;
StringBody setCompletedPart;
ByteArrayBody fileContentPart;
//... 用数据填充变量... //

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

C++ Qt

QHttpMultiPart* multiPartData = new QHttpMultiPart( QHttpMultiPart::FormDataType );
QBuffer* buffer = new QBuffer( multiPartData );
buffer->open( QIODevice::WriteOnly );
//... 用数据填充缓冲区... //
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 );

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.