API Playground

Hi,

I am trying to use the API playground.

I added the following CORS config to my app:

 <component name="org.nuxeo.cors">
  <extension target="org.nuxeo.ecm.platform.web.common.requestcontroller.service.RequestControllerService" point="corsConfig">
    <corsConfig name="all" 
                allowGenericHttpRequests="true"
                allowOrigin="*"
                allowSubdomains="true"
                supportsCredentials="true">
      <pattern>/nuxeo/*</pattern>
    </corsConfig>
  </extension>
</component>

Trying to connect, I get this:

Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/nuxeo/site/automation/login
Request Method:OPTIONS
Status Code:401 Unauthorized

Then a second is being made by the playground, and I get this:

Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/nuxeo/authentication/token?applicationName=Nuxeo%20API%20Playground&deviceId=device-176&deviceDescription=device-176&permission=rw
Request Method:OPTIONS
Status Code:302 Found

The API Playground doesn't connect to my local server. Any idea?

Thanks Nicolas

0 votes

2 answers

2322 views

ANSWER



The issue was that in Studio I included the TAG:

<component name="org.nuxeo.cors.config">

Studio generates it for you and it is not needed.

However it still doesn't work for my local setup in Eclipse. I reference localhost in the playground and it still fails. On my Cloud instance installed using apt-get, it works fine however.

Locally I get this JSON error:

code: "com.sun.jersey.api.NotFoundException"
entity-type: "exception"
message: "null for uri: http://localhost:8080/nuxeo//site/automation/login"
status: 500

I re-installed the SDK from scratch but I still get the same error. I believe this class is missing somehow in the Eclipse SDK. Or something is miss-configured.

Any idea?

0 votes



Hi,

First thing to try is to change the pattern to /nuxeo/.* as this is a regular expression.

It that doesn't work you should try connecting from an incognito tab in Google Chrome just to see if it works. (The playground stores some login information using cookies and there might be some consistency issues.)

For reference, this is what I normally use:

<component name="org.nuxeo.cors.config">
  <extension target="org.nuxeo.ecm.platform.web.common.requestcontroller.service.RequestControllerService" point="corsConfig">
    <corsConfig name="all" supportedMethods ="GET,POST,HEAD,OPTIONS,DELETE,PUT">
      <pattern>/nuxeo/.*</pattern>
    </corsConfig>
  </extension>
</component>

Hope it helps.

0 votes



Tried what you said. Still no luck. 'supportedMethods ="' has a space in you copy paste above, I presume it's not wanted.

I have the exact same config than you but I still get: 401 Unauthorized

11/28/2014

Following the doc here: http://doc.nuxeo.com/pages/viewpage.action;jsessionid=C9596A4CBA30E79132FFB382C9ED54BF?pageId=14257084

I try this: curl –verbose -H "Origin: http://www.nuxeo.com&quot; -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: X-Requested-With" -X OPTIONS http://localhost:8080/nuxeo/site/foobar/upload

I try to replace site/foobar by something else but I get various results … HTTP/1.1 302 Found or HTTP/1.1 401 Unauthorized (if I try to hit an API call)

11/28/2014

Ok, let's start from the beginning. Where did you put your CORS config ? Should be in nxserver/config/*-config.xml (I have it in nxserver/config/cors-config.xml).

Can you please post the response you get with:

curl –verbose -u Administrator:Administrator -H "Origin: http://nuxeo.github.io/api-playground&quot; -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: X-Requested-With" -X OPTIONS http://localhost:8080/nuxeo/site/automation

Do you still have the default Administrator/Administrator credentials enabled ? If not, have you tried connecting from an incognito tab in Google Chrome ?

11/28/2014