final HttpGet get = new HttpGet("https://{host}:{port}/sap/opu/odata/sap/API_CV_ATTACHMENT_SRV");
get.setHeader("X-CSRF-Token", "fetch");
get.setHeader ("Authorization", basicAuth);
final CloseableHttpAsyncClient httpClient = HttpAsyncClients.createDefault();
httpClient.start();
Future<HttpResponse> responseGet = httpClient.execute(get, new FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response2) {
System.out.println(get.getRequestLine() + "->" + response2.getStatusLine());
Header[] header = response2.getHeaders("X-CSRF-Token");
System.out.println(header[0].getValue().toString());
final HttpPost post = new HttpPost("https://{host}:{port}/sap/opu/odata/sap/API_CV_ATTACHMENT_SRV/AttachmentContentSet");
post.addHeader("Content-Type", MimeType);
post.addHeader("LinkedSAPObjectKey","AUT000000000000001000000423700000");
post.addHeader("BusinessObjectTypeName","DRAW");
post.addHeader("slug",Slug);
post.addHeader ("Authorization", basicAuth);
post.addHeader ("X-CSRF-Token", header[0].getValue());
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024*1000];
int length;
while ((length = is.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
result.toString("UTF-8");
StringEntity content;
content = new StringEntity(result.toString("UTF-8"));
post.setEntity(content);
Future<HttpResponse> response = httpClient.execute(post, new FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response2) {
// do success task
}
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
32 | |
14 | |
13 | |
12 | |
11 | |
8 | |
8 | |
7 | |
7 | |
6 |