Vorrei utilizzare un'API JIRI REST, ma non ho avuto esito positivo.Consumare un'API Jira REST
Il sito Jira ha pronunciato la seguente richiesta URL:
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
E questo è l'array JSON, che si trova su un file chiamato collector.json:
"fields": [
{
"project":
{
"key": "ATL"
},
"summary": "REST ye merry TEST.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Task"
}
}
]
}
Quello che segue è il codice:
<?php
include_once "collector.php";
$jiraValues = jsonArray("collector.json");
$jira_url = "http://jira.howareyou.org:8091/rest/api/2/issue/createmeta";
$jiraString = json_encode($jiraValues);
$request = curl_init($jira_url); // initiate curl object
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($request, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($request, CURLOPT_ENCODING, "");
curl_setopt($request, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_POSTFIELDS, $jiraString); // use HTTP POST to send form data
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
curl_setopt($request, CURLOPT_URL, $jira_url);
$json_raw = curl_exec($request); // execute curl post and store results in $json_raw
curl_close($request); // close curl object
// This line takes the response and breaks it into an array using the specified delimiting character
$jira_response = json_decode($json_raw, TRUE);
print_r($jira_response);
Quando lo eseguo, non succede nulla. Non ho feedback
L'ho trovato here e ho sostituito le informazioni con le mie informazioni valide.
Hai una risposta dal req 'cURL'? provate anche a stampare '$ json_raw' per il debugging – Pogrindis
E' più cosa, usate 'echo' il JSON di nuovo al chiamante invece di' print_r' – Pogrindis
@Pogrindis ho provato a farlo eco, ancora nessun risultato. Non sono sicuro di cosa debba essere sostituito in quella richiesta di richiamo. È la mia prima volta a occuparmene – kya