Bonjour tout le monde,
J'essaye dans Logstash, de contacter une API REST au travers d'une méthode POST quoi doit me retourner un document JSON.
Voici ma configuration:
input {
http_poller {
urls => {
getIssueForGZLProjectVersion => {
method => post
user => "bcu"
password => "changeit"
url => "https://URL/jira/rest/api/2/search"
body => '{"jql":"project = GZL && fixVersion = 19088"}'
headers => {
Accept => "application/json"
}
}
}
request_timeout => 60
schedule => { cron => "* * * * * UTC"}
codec => "json"
metadata_target => "http_poller_metadata"
}
}
Voici le message qui est retourné à Logstash:
{
"@timestamp" => 2019-07-10T06:31:00.397Z,
"@version" => "1",
"http_poller_metadata" => {
"code" => 415,
"times_retried" => 0,
"response_headers" => {
"x-seraph-loginreason" => "OK",
"x-xss-protection" => "1; mode=block",
"set-cookie" => [
[0] "JSESSIONID=F6A8F064F0B411EADD5B8489C2C2A33B;path=/jira;Secure;HttpOnly",
[1] "atlassian.xsrf.token=ALTQ-FBWF-E57B-SBIP_90f1f981930daf2276fdd632d4b847e6444f27c5_lin;path=/jira;Secure"
],
"x-ausername" => "bcu",
"content-security-policy" => "frame-ancestors 'self'",
"x-content-type-options" => "nosniff",
"connection" => "Keep-Alive",
"x-asen" => "SEN-457387",
"vary" => "User-Agent",
"keep-alive" => "timeout=5, max=300",
"server" => "Apache",
"x-asessionid" => "16kd6yx",
"x-arequestid" => "511x1069620x1",
"date" => "Wed, 10 Jul 2019 06:31:00 GMT",
"x-frame-options" => "sameorigin",
"content-type" => "text/html;charset=UTF-8",
"strict-transport-security" => "max-age=63072000; includeSubdomains;",
"transfer-encoding" => "chunked"
},
"response_message" => "415",
"host" => "logstash-jira-pipeline",
"request" => {
"auth" => {
"eager" => true,
"pass" => "changeit",
"user" => "bcu"
},
"url" => "https://URL/jira/rest/api/2/search",
"body" => "{\"jql\":\"project = GZL && fixVersion = 19088\"}",
"headers" => {
"Accept" => "application/json"
},
"method" => "post"
},
"runtime_seconds" => 0.201462,
"name" => "getIssueForGZLProjectVersion"
}
Je reçois une erreur HTTP de type 415.
Cependant, quand j'utilise la commande suivante à l'aide de curl:
curl -D- -u bcu:changeit -X POST --header "Content-Type: application/json" --data '{"jql":"project = GZL && fixVersion = 19088"}' https://URL/jira/rest/api/2/search
Je reçois bien une réponse avec un document JSON:
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 10,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "35559",
"self": "https://URL/jira/rest/api/2/issue/35559",
"key": "GZL-4870",
"fields": {
"issuetype": {
"self": "https://URL/jira/rest/api/2/issuetype/1",
"id": "1",
"description": "",
"iconUrl": "https:/URL/jira/secure/viewavatar?size=xsmall&avatarId=11273&avatarType=issuetype",
"name": "Bogue",
"subtask": false,
"avatarId": 11273
},
[...]
Une idée ?
Merci pour votre aide