Read body in alfresco Remote API post request

531 views Asked by At

I am using alfresco Remote API to perform a post call to a JavaScript based WebScript.

As alfresco shows in documentation , postcall should be:

var connector = remote.connect(ENDPOINT_ID);
connector.post(uri, body)—POSTs content to the given URI

My code is to perform post is:

 var connector = remote.connect("alfresco");
 var JSONString = connector.post("/procesador-documentos",dataObj: {
 "metod": "test",  
 });

My code to receive the post call is:

 if(requestbody.content ){
   aux = JSON.parse(requestbody.content);
   metod = aux.metod;

 }

I have tried several options to retrieve body content but I am not able to do it.

EDIT: My webscript is executed properly and works fine.

The problem is the variable requestbody.content doesnt have content but if i do

    logger.log(requestbody.content);//prints blank
    if(requestbody.content ){}//evaluated to true

How should I retrieve that information?

1

There are 1 answers

0
Oussama Werfelli On BEST ANSWER

I think that will work with eval

 var connector = remote.connect("alfresco");
 var JSONString = connector.post("/procesador-documentos",dataObj: {
 "metod": "test",  
 });

if (JSONString.status.code == status.STATUS_OK){
    var result = eval("(" + JSONString.response + ")");
}