Problem with REST API

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
abdou123
Posts: 1
Joined: 17 Apr 2019, 08:38

Problem with REST API

Post by abdou123 »

Hello evryone,

I would like to use API REST for my website using MantisBT, to test this api i would like to make a simple form using HTML and API usng php but now i am using token generated by client, i don't like to use token for i client but i want to using cookies or getting informations about the logged client not writting a fixed token in my code:

<form method="post">
Summary : <input type="text" name="Summary" size="12"><br>
Description : <input type="text" name="Description" size="12">
name_categorie : <input type="text" name="name" size="12">
project_id : <SELECT name="id" size="1">
<option value='21' >Fanvoice Design</option>
<option value='29' >Fanvoice operationnel</option>
</SELECT>
name_projet : <input type="text" name="name_project" size="12">


<input type="submit" value="OK" >
</form>

<?php

$curl = curl_init();

echo $t_current_user_id;
curl_setopt_array($curl, array(
CURLOPT_URL => "https://xxxxxxxx/api/rest/issues/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\n \"summary\": \"".$_POST["Summary"]."\",\n \"description\": \"".$_POST['Description'].''.$t_current_user_id."\",\n \"category\": {\n \"name\": \"".$_POST["name"]."\"\n },\n \"project\": {\n \t\"id\": ".$_POST["id"].",\n \"name\": \"".$_POST["name_project"]."\"\n}, \"handler\": {\n \"name\": \"".$_POST["name_project"]."\"} \n}",
CURLOPT_HTTPHEADER => array(
"Authorization: ktOb2h6po_6wHTtMVLtCHacfbhAEpo1Z",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
} ?>

instead of using autorization:token, i want to use email or somethings about the current user.

Please help me on this i'am working in this project and i want to finished ASAP.
Thank you :D
Post Reply