"Blob.AttachOnDocument api call giving 400 error.

Hi ,

While calling Blob.AttachOnDocument api getting error.

My code

HttpAutomationClient client = new HttpAutomationClient("url");
 Session session = client.getSession("myuser","mypassword");

File dummyFile = new File(myfilepath");
Object request = session.newRequest("Blob.AttachOnDocument")
 .set("document", "5eed9909-010b-4adc-8be7-2f1dca472bc3")
 .set("xpath", "file:content")
 .setInput(new FileBlob(dummyFile)).execute();

Error :

log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.PoolingClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.nuxeo.ecm.automation.client.RemoteException: Server Error
at org.nuxeo.ecm.automation.client.jaxrs.spi.Request.handleException(Request.java:221)
at org.nuxeo.ecm.automation.client.jaxrs.spi.Request.handleResult(Request.java:126)
at org.nuxeo.ecm.automation.client.jaxrs.impl.HttpConnector.execute(HttpConnector.java:143)
at org.nuxeo.ecm.automation.client.jaxrs.impl.HttpConnector.execute(HttpConnector.java:125)
at org.nuxeo.ecm.automation.client.jaxrs.spi.ConnectorHandler.execute(ConnectorHandler.java:37)
at org.nuxeo.ecm.automation.client.jaxrs.spi.DefaultSession.execute(DefaultSession.java:119)
at org.nuxeo.ecm.automation.client.jaxrs.spi.DefaultOperationRequest.execute(DefaultOperationRequest.java:174)
at com.example.nuxeo.SampleAttachFiles.main(SampleAttachFiles.java:33)
====== Remote Stack Trace:
400 - Server Error
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">h1  {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body>    </html>400 - Server Error
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>

Weird thing is , I have installed nuxeo on my local machine and one on AWS ec2 server. When pointing to localhost above code is working fine and when I am pointing to Nuxeo on ec2, I am getting this error. I tried to hit my remote nuxeo through Postman and there also it works fine.

0 votes

0 answers

2030 views

ANSWER