Mantis REST API: Summary not Specified

Deutschsprachiges Forum für Diskussionen und Fragen zu MantisBT

Moderators: Developer, Contributor

Post Reply
lukas_heyne
Posts: 4
Joined: 24 Mar 2020, 12:34

Mantis REST API: Summary not Specified

Post by lukas_heyne »

Moin zusammen,

Wenn ich über die REST API einen neuen Eintrag anlegen möchte, dann bekomme ich immer "Summary not specified" zurück.

Ich setze über curl das folgende Kommando ab:
curl --location --request POST "{URL}/mantisbt/api/rest/issues/" --header "Authorization: {Token}" --header "Content-Type: application/json" --data-raw '{"summary":"Test Summary","description":"Test Description","category":{"id":1},"project":{"id":19}}' --verbose -w "|%{http_code}"


Über stdout bekomme ich folgende Antwort:
{"message":"Summary not specified","code":11,"localized":"Ein notwendiges Feld \u201esummary\u201c war leer. \u00dcberpr\u00fcfen Sie Ihre Eingabe."}|400

Über stderr erhalte ich diesen Log:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying {URL}...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to {URL} ({URL}) port 80 (#0)

} [85 bytes data]
* upload completely sent off: 85 out of 85 bytes

{ [149 bytes data]
100 234 100 149 100 85 149 85 0:00:01 --:--:-- 0:00:01 1000
* Closing connection 0


Das --request wegzulassen habe ich schon probiert, dann steht dort stattdessen "curl: (6) Could not resolve host: POST"

Mantis Versionsdaten:
MantisBT-Version 2.24.1
Schema-Version 210
PHP-Version 7.3.20
Datenbanktreiber mysqli
Datenbankversion, Beschreibung 10.4.8, 10.4.8-MariaDB



Wie setze ich das Kommando korrekt ab um einen neuen Eintrag in Mantis anzulegen?
atrol
Site Admin
Posts: 8353
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Mantis REST API: Summary not Specified

Post by atrol »

Sehe auf den ersten schneller Blick keinen Fehler.
Folgender Aufruf funktioniert auf meinem Testsystem

Code: Select all

curl --location --request POST '<MyMantisURL>/mastertest/api/rest/issues/' \
--header 'Authorization: <MyAccessToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "summary": "This is a test issue",
  "description": "This is a test description",
  "category": {
    "id": 2
  },
  "project": {
    "id": 1
  }
}'
Please use Search before posting and read the Manual
lukas_heyne
Posts: 4
Joined: 24 Mar 2020, 12:34

Re: Mantis REST API: Summary not Specified

Post by lukas_heyne »

Der Aufruf funktioniert bei mir nicht.

curl --location --request POST "http://{url}/mantisbt/api/rest/" --header 'Authorization: {token}' --header 'Content-Type: application/json' --data-raw '{"summary": "This is a test issue", "description": "This is a test description", "category": {"id": 2}, "project": {"id": 2}}'

curl: (6) Could not resolve host: {token}'
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: This is a test issue,
curl: (6) Could not resolve host: description
curl: (6) Could not resolve host: This is a test description,
curl: (6) Could not resolve host: category
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 2
curl: (6) Could not resolve host: project
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 2
atrol
Site Admin
Posts: 8353
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Mantis REST API: Summary not Specified

Post by atrol »

Am besten exakt mein Beispielskript kopieren und <MyMantisURL> und <MyAccessToken> sowie die Projekt und Category IDs durch die Settings der eigenen Installation ersetzen.
Please use Search before posting and read the Manual
lukas_heyne
Posts: 4
Joined: 24 Mar 2020, 12:34

Re: Mantis REST API: Summary not Specified

Post by lukas_heyne »

Moin atrol,

Ich habe den Befehl von dir jetzt sowohl unter Linux als auch Windows nochmal getestet.

curl --location --request POST 'http://{url}/api/rest/issues/' --header 'Authorization: {token}' --header 'Content-Type: application/json' --data-raw '{"summary": "This is a test issue", "description": "This is a test description", "category": {"id": 1}, "project": {"id": 2}}' --verbose

Die Logs habe ich an den Post angehängt.

Sowohl unter Linux als auch unter Windows hatte ich keinen Erfolg, es wurde kein Eintrag angelegt.

Grüße,
Lukas
Attachments
windows_curl_mantis.log
(2.18 KiB) Downloaded 775 times
linux_curl_mantis.log
(1.06 KiB) Downloaded 762 times
atrol
Site Admin
Posts: 8353
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Mantis REST API: Summary not Specified

Post by atrol »

Habe gerade keine Zeit, um es mir näher anzuschauen, aber bei dem Windows System ist der erste Fehler offensichtlich

Code: Select all

* Protocol "'http" not supported or disabled in libcurl
* Closing connection -1
Hilft vielleicht weiter: https://stackoverflow.com/questions/688 ... in-libcurl
Please use Search before posting and read the Manual
lukas_heyne
Posts: 4
Joined: 24 Mar 2020, 12:34

Re: Mantis REST API: Summary not Specified

Post by lukas_heyne »

Nachdem ich den Token in Mantis widerrufen und neu angelegt habe, funktioniert es jetzt soweit unter Linux.
Warum es mit dem vorherigen Token nicht funktioniert hat weiß ich nicht.
Da ich das ganze für einen Dienst/Server verwenden werde, wird es eh unter Linux laufen, von daher wäre das Problem für mich erstmal gelöst.

Vielen Dank für die Hilfe!
Post Reply