Webscript with json request parameter

cancel
Showing results for 
Search instead for 
Did you mean: 
dhrumilgosaliya
Member II

Webscript with json request parameter

Hi everyone,

 

I have one custom search webscript with me which I am able to call from POSTMAN, in which I need to send 5 different values in json format and I get the related document in response. Now I want to call this webscript from custom share surf page. I have created one surf page and added 5 textbox and 1 button in that page now how can I call webscript with json request parameter to get the same response I'm getting from POSTMAN.

 

Thanks,

Dhrumil

2 Replies
sanjaybandhniya
Intermediate

Re: Webscript with json request parameter

Hi,

Please follow below tutorial.

Webscript 

abhinavmishra14
Advanced

Re: Webscript with json request parameter

To call a repository webscript you can do something similar to the below example:

 

   //JSON Payload
	var searchPayload = {
	   "offerName":"test",
	   "offerPrice":"$100"
	}
	
    Alfresco.util.Ajax.request({
	        //e.g.: http://localhost:8080/alfresco/service/searchOffers
    	        url : Alfresco.constants.PROXY_URI + "/searchOffers",
    	        requestContentType:Alfresco.util.Ajax.JSON,
		responseContentType:Alfresco.util.Ajax.JSON,
		dataObj:searchPayload,
		method:Alfresco.util.Ajax.POST,
timeout:180000,
successCallback : { fn : function (response) { //TODO:: do something with response }, scope : this }, failureCallback : { fn : function (response) { //TODO:: do something in case of failure response }, scope : this } });

You can refer to this post as well, its quite old but may be helpful: https://blog.arvixe.com/webscript-call-in-client-side-javascript-of-alfresco/

 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)