Hello, why my post was marked as a spam. What I need to change to solve this problem?
Link to post:
(Problem with processing POST JSON request)
by h_john
https://hub.alfresco.com/t5/alfresco-content-services-forum/problem-with-processing-post-json-reques...
<p>Hello.</p><p>I`m trying to make a webscript which will be able to:</p><p>1. receive json request;<br />2. get and transform argument from json request to java format;<br />3. find node in a specific folder using json argument as a search request;<br />4. get properties from found node;<br />5. transform found properties back to json string;<br />6. send answer in json;</p><p>Example of json request that I want to process </p><pre>$postData = array(
'didNumber' => '0443334000',
'srcNumber' => '0670219424',
'companyID' => '3041',
'requestType' => 'gettingCallSettings'
);</pre><p>I`ve created next files after reading about json processing in Alfresco:</p><p>.get.desc.xml</p><pre><webscript>
<shortname>negotiate</shortname>
<description>negotiate JSON</description>
<url>/negotiate</url>
<authentication>guest</authentication>
<negotiate accept="application/json">json</negotiate>
</webscript></pre><p>.get.json.ftl</p><pre>{"response": "myObjAsString"}</pre><p>.get.js</p><pre> var tel = json.get("srcNumber");
var node = search.luceneSearch("@cm\\:name:\"" + nodeName+ "\" AND PARENT:\"workspace://SpacesStore/61d28f13-24e0-434a-8b90-5ea54d2fafa2\"");
var name = node.properties["zkz:Name"];
var myObj = {'name':'name'};
var myObjAsString = jsonUtils.toJSONString(myObj);
model.myObjAsString = myObjAsString;</pre><p>But every time I try to execute my srcipt I receive something like this:</p><pre>{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message" : "09220628 Cannot locate template processor for template org\/alfresco\/negotiate.get.json",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 09220628 Cannot locate template processor for template org\/alfresco\/negotiate.get.json",</pre><p>or if I clean all data from .get.js I receive text from .ftl file.</p><p>In the end I need to send back something like this:</p><pre>die(json_encode(array(
'customerData' => array(
'name' => '1111111',
'description' => '11111111111',
)
)));</pre><p>Please, can someone help me with js file? Can it be on Java or it must be in Json format?</p><p> </p>
This message has 0 replies