View ProjeQtOr On SourceForge.net
ProjeQtOr free project management software - ERROR:data is not correctly encoded for method PUT. Request for correct API KEY - ProjeQtOr
 

ERROR:data is not correctly encoded for method PUT. Request for correct API KEY

More
11 Dec 2017 13:17 #1 by Stephan123
I have followed the instructions in your ProjeQtor REST API Specifications document and can successfully interact with the REST Web Service using the GET method. However, when using the POST or PUT methods, I get the following error: "data' is not correctly encoded for method PUT. Request for correct API KEY". For the testing purposes, I'm using the exact PHP code for the POST request as per the spec document. I'm testing on Projeqtor version 6.2.5.

I have gone through the following debugging steps:

1. Confirmed the correct access username and password is specified for the user"projeqtor":
curl_setopt($curl, CURLOPT_USERPWD, "projeqtor:my_pwd" ) ;
Apache grants access with correct password. Test with wrong password results in access failure, with error message in Apache log file. I have set up the .htaccess file to point to the correct .htpasswd file location. .htpasswd contains the generated password for user "projeqtor".

2. Confirmed that the AES 256 encryption of the test data is working in the PHP file, using the API key for user "projeqtor" as shown in >> Environmental parameters >> Users >> user=projeqtor . I echo'd the encrypted $data to my browser to confirm its encrypted.

3. I have triple checked every digit of the API key to ensure it was correctly copied into the PHP file.

4. I have kept the data for encryption as simple as possible: $data = '{"id:"1", "name":"new name"}'

4. The response from curl_exec gives the error: "data' is not correctly encoded for method PUT. Request for correct API KEY".

I'm not a PHP programmer (I mostly use Python to execute restful API interfaces). I was hoping to use Projeqtor with a REST API that is purely specified in URL fromat, without the need for the user to get involved in the PHP server pages that underlies the URL call.

I'd appreciate if you could indicate any possible cause of the error.
regards,
Stephan

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

More
12 Dec 2017 09:56 #2 by babynus
Diffucult to investigate.
It seems you did things the ggod way.

I tested that API has no issue : all works fine on my side.

Babynus
Administrator of ProjeQtOr web site

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

More
13 Dec 2017 10:41 #3 by Stephan123
Txs for your response.

It seems the encrypt function works correct, but the decrypt function returns an empty string. I have disabled encryption-decryption for the moment whilst testing POST and PUT by sending the data un-encrypted and 'short-circuiting' decrpytion in the /projeqtor/api/index.php file as follows:

$dataEncoded = file_get_contents("php://input");
$data=$dataEncoded; //$data=AesCtr::decrypt($dataEncoded, $user->apiKey, Parameter::getGlobalParameter('aesKeyLength')); //DISABLED THE ENCRYPTION-DECRYPTION.

I can POST and PUT successfully, so my testing is not held back for the moment :-)

I'm running PorjeQtOr on Ubuntu 16.04 with Bitnami LLAP. I will dig deeper into the AES 256 decrypt function in the next few days...

kind regards,
Stephan

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

More
17 Dec 2017 12:59 #4 by babynus
did you try and set
$aesKeyLength=256;
in parameters.php

If my remembering is correct, we set it by defaut to 128 because aes encryptions with key menght 256 is illegal in some countries.

Babynus
Administrator of ProjeQtOr web site

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

Moderators: babynusprotion
Time to create page: 0.040 seconds