Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to submit a POST request to Apache Syncope API in node.js?
    text
    copied!<p>Salam (means Hello) :)</p> <p>In my node.js application, I am trying to add a user to Apache Syncope via its RESTful API. Apache Syncope is installed on a remote VPS and <a href="https://cwiki.apache.org/confluence/display/SYNCOPE/Calling+RESTful+services+from+CLI#CallingRESTfulservicesfromCLI-Exportdatabasecontent" rel="nofollow">this article</a> demonstrate this process in a PHP environment. here is what I did in my node.js application:</p> <pre><code>http.createServer(onRequest).listen(80); function onRequest (request, response) { var options = { hostname: MY_VPS_IP, port: 8080, path: '/syncope/rest/user/create.json', auth: 'admin:password', method: 'POST' }; var data = {an: 'object', of: 'new', user: 'data' }; var req=http.request(options, function(res) { var body; res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { response.writeHead(200, { 'Content-Type': 'text/html' }); response.end(body, 'utf-8'); }); }); req.end(JSON.stringify(data)); } </code></pre> <p>The response of Apache Syncope is a 415 error (css styles omitted):</p> <pre><code>undefined &lt;html&gt; &lt;head&gt;&lt;title&gt;Apache Tomcat/7.0.42 - Error report&lt;/title&gt; &lt;/head&gt; &lt;body&gt;&lt;h1&gt;HTTP Status 415 - &lt;/h1&gt; &lt;HR size="1" noshade="noshade"&gt; &lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt; &lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.&lt;/u&gt;&lt;/p&gt; &lt;HR size="1" noshade="noshade"&gt; &lt;h3&gt;Apache Tomcat/7.0.42&lt;/h3&gt;&lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload