Jump to content
We've recently updated our Privacy Statement, available here ×

rest api sample example not working


masteryoda

Recommended Posts

the example given here --  http://community.jaspersoft.com/wiki/getting-started-rest-web-service-api is not working . i have done everything mentioned there but it is giving this error

 

 
E:restapicodesample>mvn test
[iNFO] Scanning for projects...
[iNFO]
[iNFO] ------------------------------------------------------------------------
[iNFO] Building REST Code Sample 1.0-SNAPSHOT
[iNFO] ------------------------------------------------------------------------
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons
-io:commons-io:jar:1.3.2
[iNFO]
[iNFO] --- maven-resources-plugin:2.6:resources (default-resources) @ RESTCodeSample ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build i
s platform dependent!
[iNFO] skip non existing resourceDirectory E:restapicodesamplesrcmainresources
[iNFO]
[iNFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ RESTCodeSample ---
[iNFO] Nothing to compile - all classes are up to date
[iNFO]
[iNFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ RESTCodeSample
 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build i
s platform dependent!
[iNFO] skip non existing resourceDirectory E:restapicodesamplesrctestresources
[iNFO]
[iNFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ RESTCodeSample --
-
[iNFO] Nothing to compile - all classes are up to date
[iNFO]
[iNFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ RESTCodeSample ---
[iNFO] Surefire report directory: E:restapicodesampletargetsurefire-reports
 
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest
log4j:WARN No appenders could be found for logger (com.jaspersoft.jasperserver.rest.sample.R
estAPIUtils).
log4j:WARN Please initialize the log4j system properly.
 INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] sending Request. url: http://lo
calhost:8080/jasperserver-pro/rest/resource req verb: PUT
 INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] response status line: HTTP/1.1
403 Forbidden
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.353 sec <<< FAILURE!
com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest  Time elapsed: 0.353 sec  <<<
FAILURE!
java.lang.AssertionError: basic response check did not pass
        at org.junit.Assert.fail(Assert.java:91)
        at org.junit.Assert.assertTrue(Assert.java:43)
        at com.jaspersoft.jasperserver.rest.sample.RestAPIUtils.sendAndAssert(RestAPIUtils.j
ava:123)
        at com.jaspersoft.jasperserver.rest.sample.RestAPIUtils.sendAndAssert(RestAPIUtils.j
ava:117)
        at com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest.setUp(BasicResource
CRUDTest.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:
44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:1
5)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41
)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.jav
a:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUt
ils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFac
tory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.j
ava:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.jav
a:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
 
 
Results :
 
Failed tests:   com.jaspersoft.jasperserver.rest.sample.BasicResourceCRUDTest: basic respons
e check did not pass
 
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
 
[iNFO] ------------------------------------------------------------------------
[iNFO] BUILD FAILURE
[iNFO] ------------------------------------------------------------------------
[iNFO] Total time: 1.538s
[iNFO] Finished at: Tue Jul 23 18:11:36 IST 2013
[iNFO] Final Memory: 7M/111M
[iNFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (d
efault-test) on project RESTCodeSample: There are test failures.
[ERROR]
[ERROR] Please refer to E:restapicodesampletargetsurefire-reports for the individual test
 results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the follow
ing articles:
E:restapicodesample>
 
//-------------------------------------------------------------------------
Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi materyoda,

It seems that the test should login first.
The 403 Forbidden  message that your getting means that no authentication has been performed.

Can walso mean that credentials from tests are wrong.

Please check if all that credentials match.

kind regards,

Paulo

 

Link to comment
Share on other sites

Hi pssp25

I have logged in using the username- jasperadmin and password- jasperadmin as specified in the Consts.java of the example. and i have also checked the credentials from the test. but still it is not working. i am new to jasperserver and have read the documents but cannot figure out what is the problem ... please any suggestions....

Link to comment
Share on other sites

 

I used the following parameters to do a successful login:

1) orgId

2) j_username

3) j_password

4) j_password_pseudo

 

Example of Login.

Login Link

HTML file with button and link to automatically login. Not that the credentials are in the HTML file. This is not SSO.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...