I am new to crossref I am working for e-publishing. I have a task to push data to crossref automatically via HTTP post.
When I post the data via an HTTP post, I am getting 200 responses.
host: https://0-doi-crossref-org.lib.rivier.edu/servlet/deposit
But the article is not reflected in the cross-ref site
Here, I have copied the HTTP postcode for your reference,
public HashMap<String, Object> crossrefUploadTool(String metaFile, HashMap<String, Object> eachSpub)
throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
String metaFileName = new File(metaFile).getName();
HashMap<String, Object> responseObj = new HashMap<String, Object>();
SSLContext sslContext = SSLContextBuilder.create().loadTrustMaterial(new TrustSelfSignedStrategy()).build();
HostnameVerifier allowAllHosts = new NoopHostnameVerifier();
SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, allowAllHosts);
CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(connectionFactory).build();
System.out.println(“redirectUri:::” + eachSpub.get(“host”));
org.apache.http.client.methods.HttpPost post;
String responseString = null;
try {
post = new org.apache.http.client.methods.HttpPost(eachSpub.get(“host”) + “?operation=doMDUpload?login_id=”
- eachSpub.get(“username”) + “?” + “login_passwd=” + eachSpub.get(“password”));
post.setHeader(“Accept”, “image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, /”);
post.setHeader(“Content-Type”, “multipart/form-data;boundary=---------------------------7d22911b10028e”);
post.setHeader(“User-Agent”, “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)”);
post.setHeader(“Accept-Language”, “en-us”);
post.setHeader(“Content-Disposition”, “form-data; name=fname” + “; filename=” + metaFileName);
File file = new File(metaFile);
FileEntity entity = new FileEntity(file);
post.setEntity(entity);
CloseableHttpResponse postresponse = client.execute(post);
responseString = org.apache.http.util.EntityUtils.toString(postresponse.getEntity());
responseObj = (HashMap<String, Object>) Utils.stringToMap(responseString);
post.releaseConnection();
responseObj.put(“statusCode”, postresponse.getStatusLine().getStatusCode());
if (postresponse.getStatusLine().getStatusCode() == 200) {
responseObj.put(“response”, responseString);
} else {
responseObj.put(“response”, “400 Bad Request error”);
}
responseObj.put(“success”, 1);
System.out.println(“responseObj:::” + responseObj);
System.out.println(“responseString:::” + responseString);
client.close();
} catch (Exception e1) {
responseObj.put(“response”, true);
e1.printStackTrace();
}
return responseObj;
}