cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting as csv

johan1974
Champ in-the-making
Champ in-the-making
Hello,

I like to export some data with a webscript in a csv format. Where can i find a good explanation how to do this?

Thnx!
15 REPLIES 15

johan1974
Champ in-the-making
Champ in-the-making
hmm it looks you are right. The starting line is

http://localhost:8080/alfresco/service/docaudit/Data%20Dictionary.csv?format=csv&d=&u=&s=userIdentif...

So it seems the demo is not working correctly. I am getting lost here now. Any suggestions?  Smiley Sad

mikeh
Star Contributor
Star Contributor
I'm not familiar with that particular example webscript, but it sounds like it's not really an avenue worth exploring unless you're already comfortable developing webscript of your own.

I would start off at the beginning: create a "hello world" webscript, e.g. johan.get.csv.ftl with the content
"hello", "world"

Once you've got that foundation in place, you can build on adding functionality without also having to understand somebody else's work.

Thanks,
Mike

johan1974
Champ in-the-making
Champ in-the-making
Ok i am trying a basic helloworld example. The html works fine but still has some trouble with the csv. I have now this :

helloworld.get.desc.xml 

<webscript>
  <shortname>Hello World</shortname>
  <description>Hello World</description>
  <url>/HelloWorld</url>
  <format default="html">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>

helloworld.get.html.ftl

<html>
<HEAD></HEAD>
<BODY>
<h1>Hello World</h1>
</BODY>
</html>

helloworld.get.csv.ftl

"hello", "world"



When i use the url http://localhost:8080/alfresco/service/HelloWorld i get perfectly the message hello world, no problem there. But when i want to call the csv i use http://localhost:8080/alfresco/service/HelloWorld?Format=csv i get the default html output.

I also tried to change the helloworld.get.csv.ftl to helloworld.get.txt.ftl and then call http://localhost:8080/alfresco/service/HelloWorld?Format=txt but with the same results.

What am i forgetting here?  :?

mikeh
Star Contributor
Star Contributor
Try this URL: http://localhost:8080/alfresco/service/HelloWorld.csv

If you want http://localhost:8080/alfresco/service/HelloWorld to bring back the csv template instead of html, update the description file to:
<format default="csv"></format>

Thanks,
Mike

johan1974
Champ in-the-making
Champ in-the-making
Still no luck, i tried both your suggestions and got this error again.

Alfresco     Web Script Status 500 - Internal Error

The Web Script /alfresco/service/HelloWorld.csv has responded with a status of 500 - Internal Error.

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.

Message:   Web Script format 'csv' is not registered

Exception:   org.alfresco.web.scripts.WebScriptException - Web Script format 'csv' is not registered
   
   org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:93)
   org.alfresco.web.scripts.WebScriptRuntime.wrappedExecute(WebScriptRuntime.java:364)
   org.alfresco.web.scripts.WebScriptRuntime$1.execute(WebScriptRuntime.java:330)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:241)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:171)
   org.alfresco.web.scripts.WebScriptRuntime.transactionedExecute(WebScriptRuntime.java:341)
   org.alfresco.web.scripts.WebScriptRuntime.authenticatedExecute(WebScriptRuntime.java:284)
   org.alfresco.web.scripts.WebScriptRuntime.executeScript(WebScriptRuntime.java:150)
   org.alfresco.web.scripts.WebScriptServlet.service(WebScriptServlet.java:109)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   java.lang.Thread.run(Thread.java:619)
   
Server:   Alfresco Enterprise Network v2.2.0 (159) schema 89
Time:   1-mei-2008 15:58:19

Diagnostics:   Inspect Web Script (helloworld.get)

Smiley Sad

mikeh
Star Contributor
Star Contributor
Sorry, my bad.

You'll either have to go with "txt" instead of "csv" or add csv as a webscript format. See this article on the wiki for details on how to do that.

Thanks,
Mike