View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - API evolution - a search web service - ProjeQtOr
 
 

API evolution - a search web service

More
10 Aug 2014 12:27 #1 by mamath
Hi,

First, thank you for your excellent work on the API. It's a very interesting functionnality.
Two point :
- Question : is it necessary too encrypt message (with AES-256) if i call the web service using https ? I try too call the web service using microsoft WinHttpRequest. and i have lot of problem with encryption.
- Propose Evolution : add a service for search elements with criteria. Sample : if i want know if a project named "Project ONE" exist, i can ask this web service with a criteria : '{"name":"Project ONE"}'. This evolution can help, if we want check existence of object before using insert or update WS.

I can give you the code i have developed.

Regards

Please Log in or Create an account to join the conversation.

More
10 Aug 2014 13:21 #2 by babynus

Question : is it necessary too encrypt message (with AES-256) if i call the web service using https ? I try too call the web service using microsoft WinHttpRequest. and i have lot of problem with encryption.

Yes, encryption is mandatory. It is a security constraint, not to crypt data, but to confirm you have the correct API Key. Security (to retrive access rights) is in two points :
- you have to connect with correct user/password (means you have an account)
- you provide the correct API key (in fact you don't really provide it, you use it to code data) : this means the admin gave you this API key, and is OK for you to post data through the API.

Propose Evolution : add a service for search elements with criteria. Sample : if i want know if a project named "Project ONE" exist, i can ask this web service with a criteria : '{"name":"Project ONE"}'. This evolution can help, if we want check existence of object before using insert or update WS.

Request recorded as Ticket #1490

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
12 Aug 2014 19:00 #3 by mamath
Hi,

Thank you for your answer.
For the Ticket #1490, if you want i have develop the functionality in a simple way (I have add a case like "filter", but named "search").
If you want you can use the following code:
else if (count($split)==2 and $split[1]=='search') {  // =============== uri = {OblectClass}/search
		    	if (isset($_REQUEST['data']) ) {
		    		$data=$_REQUEST['data'];
		    	} else {
		    		$data=file_get_contents("php://input");
		    	}
		    	if (! $data) {
		    		returnError($invalidQuery, "'data' missing for method ".$_SERVER['REQUEST_METHOD']);
		    	}
		    	$dataArray=@json_decode($data,true);
		    	if (! $dataArray) {
		    		returnError($invalidQuery, "'data' is not correctly encoded for method ".$_SERVER['REQUEST_METHOD'].". Request for correct API KEY");
		    	}
		    	if (isset($dataArray['items'])) {
		    		$arrayData=$dataArray['items'];
		    	} else {
		    		$arrayData=array($dataArray);
		    	}
		    	$where="1=1 ";
		    	
		    	foreach ($arrayData[0] as $field=>$value) {
		    		$where.="and " . $field . "='" .$value . "' ";
		    	}
        }

best regards
The following user(s) said Thank You: babynus

Please Log in or Create an account to join the conversation.

More
13 Aug 2014 16:58 #4 by babynus
Note added to Ticket #1490

Thanks

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
08 Sep 2014 10:21 #5 by mamath
Hi,

I have modify my proposed code to add to the search service the capability to use "OR" conditions.
for exemple if you want to get activity close OR canceled, you can send a query like : {"identifier":"id","items":[{"idStatus":"7"},{"idStatus":"9"}]}
else if (count($split)==2 and $split[1]=='search') {  // =============== uri = {OblectClass}/search
		    	if (isset($_REQUEST['data']) ) {
		    		$data=$_REQUEST['data'];
		    	} else {
		    		$data=file_get_contents("php://input");
		    	}
		    	if (! $data) {
		    		returnError($invalidQuery, "'data' missing for method ".$_SERVER['REQUEST_METHOD']);
		    	}
		    	$dataArray=@json_decode($data,true);
		    	if (! $dataArray) {
		    		returnError($invalidQuery, "'data' is not correctly encoded for method ".$_SERVER['REQUEST_METHOD'].". Request for correct API KEY");
		    	}
		    	if (isset($dataArray['items'])) {
		    		$arrayData=$dataArray['items'];
		    	} else {
		    		$arrayData=array($dataArray);
		    	}
		    	$where=(count($arrayData))>0?"(1=0 ":"(1=1";
		    	foreach ($arrayData as $arrayFilter) {
		    		$where.="or (1=1 ";
			    	foreach ($arrayFilter as $field=>$value) {
			    		$where.="and " . $field . "='" .$value . "' ";
			    	}
			    	$where.=') ';
		    	}
		    	$where.=') ';
		    }

Please Log in or Create an account to join the conversation.

More
08 Sep 2014 13:53 #6 by babynus
Hi,

Thanks for this new code.
Added as note on Ticket #1490.

But I'm not sure a "OR" condition should be used.
In most cases, several criterias means "AND" conditions (as in Filters pop-up).

Have to be studied.
Anyhow, Thanks for your contribution

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.036 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.