on 04-14-2016 9:13 AM
Hi,
How to add image on report page header using Rest API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dan,
I am using Rest plugin for report creation ,for request body,can I follow the same format mentioned in step1 of above post?,
I tried mentioning details inside request body based on same format but received below error
Adding request details along with body below which I mentioned
Request: http://abc:6405/biprws/raylight/v1/documents/19863/attachments
Accept: application/xml
Content-Type: application/xml
Request Body:
Multipart boundary: ------------------987654321
Part[0] key: attachmentInfos
Part[0] content-Type: application/xml
Part[1] key: attachmentContent
Part[1] filename: Tulips.jpeg
Part[1] content-Type: image/jpeg
Error:
hi Vaibhav,
... and sorry: I wrote a typo in the post Dan mentioned. I'll edit it ASAP.
As explained in the documentation available from http://help.sap.com, the Content-Type should be multipart/form-data.
Regards,
eric
Hi Eric,
I have changed Content-Type to multipart/form-data.as suggested above keeping rest of the things same but getting below error, do I need to apply any change in above mentioned request body ?
Error
Vaibhav,
If you mean:
Multipart boundary: ------------------987654321
Part[0] key: attachmentInfos
Part[0] content-Type: application/xml
Part[1] key: attachmentContent
Part[1] filename: Tulips.jpeg
Part[1] content-Type: image/jpeg
as request body, this is not correct. These were just console outputs from our internal test framework.
The documentation, available from http://help.sap.com, shows an example in section "Adding an Attachment" (it's for example section 8.1.20.2 for 4.1/SP7 documentation).
Regards,
eric
Hi Eric,
I have mentioned below request details but getting error, please suggest where I am lacking
Request: http://abc:6405/biprws/raylight/v1/documents/19863/attachments
Content-Type: multipart/form-data
Accept: application/xml
Body:
<attachment>
<name>Tulips</name>
<mimeType>image/jpeg</mimeType>
</attachment>
--------------------####boundary123456798
<attachment>
<name>Tulips</name>
<mimeType>image/jpeg</mimeType>
</attachment>
--------------------####boundary123456798
Content-Disposition: form-data; name=""attachmentContent""; filename=""Tulips.jpeg""
Content-Type: image/jpeg
--------------------####boundary123456798
Error:
- <error>
- <error_code>100</error_code>
- <message>Rule not respected (Argument 'nbAttachments' must be greater than 1)</message>
- <stack_trace>com.sap.webi.raylight.RaylightException: Rule not respected (Argument 'nbAttachments' must be greater than 1)
- at com.sap.webi.raylight.context.Messenger.createException(Messenger.java:57)
- at com.sap.webi.raylight.Rules.check(Rules.java:97)
- at com.sap.webi.raylight.AbstractRaylightServiceDocument.addAttachment(AbstractRaylightServiceDocument.java:643)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
- at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
- at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:164)
- at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:242)
- at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:242)
- at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:91)
- at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
- at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
- at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
- at java.util.concurrent.FutureTask.run(FutureTask.java:138)
- at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
- at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
- at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
- at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113)
- at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:102)
- at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:464)
- at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149)
- at com.sap.bip.rs.server.servlet.BIPServletController.invoke(BIPServletController.java:93)
- at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148)
- at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
- at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
- at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
- at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
- at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
- at com.businessobjects.sdk.actionfilter.WorkflowFilter.doFilter(WorkflowFilter.java:45)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
- at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
- at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
- at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
- at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
- at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
- at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
- at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
- at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
- at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
- at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
- at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
- at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
- at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
- at java.lang.Thread.run(Thread.java:743)
- </stack_trace>
- </error>
-
Hi Vaibhav,
see the following post as well for details on how to construct the multipart/form-data request. There is also a C# sample that shows how it is pieced together.
This should help with Step 1 in the first link I mentioned. You could follow this sample except that you want to POST to:
..raylight/v1/documents/<docId/attachments
Dan
Hi Daniel,
Above post describes the procedure to upload file in folder however as per first step of the initial post suggested by you ,file or image should be attached with report , do you still want me to try uploading file in folder ?, also please correct me if my understanding is wrong
I am also pasting the error once again , in my earlier post the error was not visible
Error:
Hi Vaibhav,
the URL you should be using is the one to add an attachment to a report:
..raylight/v1/documents/<docId/attachments
The error you are getting suggests the body of the request is incorrect. Ensure you have carriage returns in the right places and that the attachment you are sending is added byte for byte into the request.
As shown in the blog about uploading files to the CMS, you can use the Fiddler tool to check out the request body to ensure it is formatted correctly.
Dan
Hi Dan,
Unfortunately I have Mozilla plugin as the only option , due to security reason I cannot download chrome plugin and fiddler , can it be done using Mozilla plugin ?, do I need to manually attach image file with Mozilla plugin while sending request?
I have changed the body as per attached screenshot but still getting same error
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.