Add CORS Content-Type to Connector - User Profile JAVA

8 views
Skip to first unread message

Patrícia Sousa

unread,
Mar 15, 2016, 2:31:35 PM3/15/16
to Alfresco Technical Discussion

I have this code:

Connector conn = FrameworkUtil.getConnector(context, ALFRESCO_ENDPOINT_ID);
ConnectorContext c = new ConnectorContext(HttpMethod.POST);
c.setContentType("application/json");

Response res = conn.call("/slingshot/profile/userprofile", c,
                    new ByteArrayInputStream(buf.toString().getBytes()));

That makes a POST to the link: POST http://localhost:8080/share/service/components/profile/userprofile

But, I got the error:

TypeError: g.getResponseHeader is undefined

...unction(g){var b=g.argument.config;var f=g.getResponseHeader["Content-Type"]||g....

In a search on the Internet, I saw that this can be a problem that is solved adding Content-Type with CORS.

Something like:

 .header("Access-Control-Allow-Headers", "x-requested-with,Content-Type");

How can I do this in my code? With Connector or ConnectorContext I don't find a way to set the header...

Reply all
Reply to author
Forward
0 new messages