CADViewer Technical Documentation, Installation Guide and Reference Samples Library

CADViewer Template REST Call Methods

Sample Call Method to the REST API

Depending on Server implementation the Ajax call (or whatever technology preferred) can be either:

  • Post call call to the End-Point Url.
  • Jsonp Post call to the End-Point Url.

A: Sample Post call to NodeJS server:

function call_server_post(data_object, tms_rest_api_url_pw){
	var	api_data = JSON.stringify(data_object);
	console.log(api_data);
	var filelist_data = {};
	filelist_data['request'] = api_data;					
	jQuery.ajax({
		url : tms_rest_api_url_pw,
		type: 'post',
		data: filelist_data,
		success:function(Api_response){
		console.log("SERVER RESPONSE POST: "+Api_response);
		var conversion_result = JSON.parse(Api_response);
		console.log("POST 2: "+conversion_result.contentStreamData);
		//window.alert("contentStreamData: "+conversion_result.contentStreamData);
		// open window with extracted json or svg
		window.open(conversion_result.contentStreamData);
		}	
	});
}

B: Sample Jsonp post call to PHP server, the Jsonp parameter is set as “tms_restful_api”:

function call_server_jsonp(data_object, tms_rest_api_url_pw){
	var	api_data = JSON.stringify(data_object);
	console.log(api_data);
	var url_json = "";
	url_json = tms_rest_api_url_pw+"?json="+api_data;
    jQuery.ajax({
        url : url_json,
        jsonp: "tms_restful_api",
        dataType: 'jsonp',
        async: false,
        success:function(Api_response){
            console.log("JSONP SERVER RESPONSE: "+Api_response);
            var conversion_result = JSON.parse(Api_response);
            console.log("JSONP 2: "+conversion_result.contentStreamData);
            //window.alert("contentStreamData: "+conversion_result.contentStreamData);
            // open window with extracted json or svg
            window.open(conversion_result.contentStreamData);
		}	
	});
}
Last updated on 17 Mar 2022
Published on 13 Mar 2020