REST API- Summary not specified

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

REST API- Summary not specified

Post by theo harsant »

Hello every one,
I am currently trying to create an issue using the REST API and MantisBT version 2.23.0. Identification works, but I then get an html 400 error ("Summary not specified"), even though I actually provide it in the json of my query (see attachment). Has any one faced a comparable issue before?
Attachments
requete curl mantis create - MantisHelp.txt
(2.18 KiB) Downloaded 547 times
obmsch
Posts: 26
Joined: 26 Mar 2013, 22:19

Re: REST API- Summary not specified

Post by obmsch »

I don't use curl myself, but I guess "--data-urlencode" is the problem here. You might have a look at the rest api documentation:
https://documenter.getpostman.com/view/ ... pi/7Lt6zkP
The samples there use "--data-raw".

And "category_id":"1" is surely wrong. That should be "category={"id"="1"}".
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

Thank you very much for your reply! I actually used the api documentation you linked, using the parameter --data-raw does not change the behaviour I reported. As for category_id, it is a mandatory field in my use case. Switching to your syntax with "category_id={"id"="1"}" sadly does not alleviate my summary issue.
obmsch
Posts: 26
Joined: 26 Mar 2013, 22:19

Re: REST API- Summary not specified

Post by obmsch »

Running the following from a cmd on Win10, local MantisBT 2.23.0 (personal information -> ?):

Code: Select all

curl --trace-ascii - --location --request POST "http://mantisbt/api/rest/issues/" ^
--header "Authorization: ?" ^
--header "Content-Type: application/json" ^
--data-raw "{\"summary\": \"This is a test issue\",\"description\": \"This is a test description\",\"category\": {\"id\": 1},\"project\": {\"id\": 58}}"
works for me. Output:

Code: Select all

Note: Unnecessary use of -X or --request, POST is already inferred.
== Info:   Trying 127.0.0.1...
== Info: TCP_NODELAY set
== Info: Connected to mantisbt (127.0.0.1) port 80 (#0)
=> Send header, 191 bytes (0xbf)
0000: POST /api/rest/issues/ HTTP/1.1
0021: Host: mantisbt
0031: User-Agent: curl/7.55.1
004a: Accept: */*
0057: Authorization: ?
0088: Content-Type: application/json
00a8: Content-Length: 123
00bd:
=> Send data, 123 bytes (0x7b)
0000: {"summary": "This is a test issue","description": "This is a tes
0040: t description","category": {"id": 1},"project": {"id": 58}}
== Info: upload completely sent off: 123 out of 123 bytes
<= Recv header, 40 bytes (0x28)
0000: HTTP/1.1 201 Issue Created with id 817
<= Recv header, 63 bytes (0x3f)
0000: Cache-Control: no-store, no-cache, must-revalidate, max-age=0
<= Recv header, 32 bytes (0x20)
0000: Content-Type: application/json
<= Recv header, 46 bytes (0x2e)
0000: Last-Modified: Mon, 09 Dec 2019 07:51:54 GMT
<= Recv header, 28 bytes (0x1c)
0000: Server: Microsoft-IIS/10.0
<= Recv header, 26 bytes (0x1a)
0000: X-Powered-By: PHP/7.3.14
<= Recv header, 68 bytes (0x44)
0000: Set-Cookie: PHPSESSID=??????????????????????????; path=/; HttpOn
0040: ly
<= Recv header, 23 bytes (0x17)
0000: X-Mantis-Username: ??
<= Recv header, 33 bytes (0x21)
0000: X-Mantis-LoginMethod: api-token
<= Recv header, 26 bytes (0x1a)
0000: X-Mantis-Version: 2.23.0
<= Recv header, 37 bytes (0x25)
0000: Date: Fri, 31 Jan 2020 19:04:01 GMT
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 943
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 943 bytes (0x3af)
0000: {"issue":{"id":817,"summary":"This is a test issue","description
0040: ":"This is a test description","project":{"id":58,"name":"RestCl
0080: ientTest"},"category":{"id":1,"name":"Allgemein"},"reporter":{"i
00c0: d":3,"name":"??","real_name":"?????????????????????","email":"??
0100: ?????????????????????"},"status":{"id":10,"name":"new","label":"
0140: new","color":"#fcbdbd"},"resolution":{"id":10,"name":"open","lab
0180: el":"open"},"view_state":{"id":10,"name":"public","label":"publi
01c0: c"},"priority":{"id":30,"name":"normal","label":"normal"},"sever
0200: ity":{"id":50,"name":"minor","label":"minor"},"reproducibility":
0240: {"id":70,"name":"have not tried","label":"have not tried"},"stic
0280: ky":false,"created_at":"2020-01-31T20:04:01+01:00","updated_at":
02c0: "2020-01-31T20:04:01+01:00","history":[{"created_at":"2020-01-31
0300: T20:04:01+01:00","user":{"id":3,"name":"??","real_name":"???????
0340: ??????????????","email":"???????????????????????"},"type":{"id":
0380: 1,"name":"issue-new"},"message":"New Issue"}]}}
You didn't provide any info about your environment, so line continuation (^) and escape (\) nay differ.
Use the " --trace-ascii - " option and look at the data that is really sent (size, content).
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

I am also running the command through windows 10 with cmd. I formatted the query so that the data-raw part fits in one line (to remove the need for escape characters in the json). The trace-ascii states that all the data is sent, which rules out a malformed json.
obmsch
Posts: 26
Joined: 26 Mar 2013, 22:19

Re: REST API- Summary not specified

Post by obmsch »

Just to be sure that the send data is really valid json. Have you cross-checked that
with any JSON viewer? Please provide that part of the trace output.
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

I used https://jsonformatter.org/ to assert the validity of the json. Here is the verbose output :
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

I used https://jsonformatter.org/ to assert the validity of the json. Here is the verbose output :

Code: Select all

=> Send header, 222 bytes (0xde)
0000: POST /api/rest/issues HTTP/1.1
0020: Host: mantis.sfr-ftth.com
003b: User-Agent: curl/7.55.1
0054: Accept: */*
0061: Authorization:xxxxxxxxxxxxxx
0091: Content-Type:application/json
00b0: Content-Length: 1523
00c6: Expect: 100-continue
00dc:
<= Recv header, 23 bytes (0x17)
0000: HTTP/1.1 100 Continue
=> Send data, 1523 bytes (0x5f3)
0000: {summary:summarysample,category_id:1,description:Description,pro
0040: ject:{id:11,name:Test},custom_fields:[{field:{id:custom_field_10
0080: ,name:custom_field_10},value:va},{field:{id:custom_field_11,name
00c0: :custom_field_11},value:00000},{field:{id:custom_field_12,name:c
0100: ustom_field_12},value:vav},{field:{id:custom_field_13,name:custo
0140: m_field_13},value:Beton},{field:{id:custom_field_14,name:custom_
0180: field_14},value:Casse},{field:{id:custom_field_15,name:custom_fi
01c0: eld_15},value:Oui},{field:{id:custom_field_32,name:custom_field_
0200: 32},value:Detendu},{field:{id:custom_field_16,name:custom_field_
0240: 16},value:Facade},{field:{id:custom_field_23,name:custom_field_2
0280: 3},value:vpl},{field:{id:custom_field_24,name:custom_field_24},v
02c0: alue:99},{field:{id:custom_field_21,name:custom_field_21},value:
0300: Chaussee},{field:{id:custom_field_22,name:custom_field_22},value
0340: :Cassee},{field:{id:custom_field_25,name:custom_field_25},value:
0380: var},{field:{id:custom_field_26,name:custom_field_26},value:Ouve
03c0: rte},{field:{id:custom_field_29,name:custom_field_29},value:Oui}
0400: ,{field:{id:custom_field_30,name:custom_field_30},value:Oui},{fi
0440: eld:{id:custom_field_31,name:custom_field_31},value:vac},{field:
0480: {id:custom_field_27,name:custom_field_27},value:2.5},{field:{id:
04c0: custom_field_28,name:custom_field_28},value:50.5},{field:{id:cus
0500: tom_field_17,name:custom_field_17},value:Collectivite},{field:{i
0540: d:custom_field_18,name:custom_field_18},value:vdn},{field:{id:cu
0580: stom_field_19,name:custom_field_19},value:vde},{field:{id:custom
05c0: _field_20,name:custom_field_20},value:0123456789}]}
== Info: We are completely uploaded and fine
<= Recv header, 36 bytes (0x24)
0000: HTTP/1.1 400 Summary not specified
<= Recv header, 21 bytes (0x15)
0000: Server: nginx/1.9.3
<= Recv header, 37 bytes (0x25)
0000: Date: Mon, 03 Feb 2020 09:21:57 GMT
<= Recv header, 32 bytes (0x20)
0000: Content-Type: application/json
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 195
<= Recv header, 24 bytes (0x18)
0000: Connection: keep-alive
<= Recv header, 25 bytes (0x19)
0000: X-Powered-By: PHP/7.4.1
<= Recv header, 74 bytes (0x4a)
0000: Set-Cookie: PHPSESSID=40ddeba34124640a37f2fb41bbbee3eb; path=/;
0040: HttpOnly
<= Recv header, 39 bytes (0x27)
0000: Cache-Control: private, max-age=10800
<= Recv header, 46 bytes (0x2e)
0000: Last-Modified: Wed, 08 Jan 2020 13:56:17 GMT
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 195 bytes (0xc3)
0000: {"message":"Summary not specified","code":11,"localized":"Le cha
0040: mp obligatoire \u00ab\u202fsummary\u202f\u00bb n\u2019est pas re
0080: nseign\u00e9. Veuillez v\u00e9rifier \u00e0 nouveau votre saisie
00c0: ."}
{"message":"Summary not specified","code":11,"localized":"Le champ obligatoire \u00ab\u202fsummary\u202f\u00bb n\u2019est pas renseign\u00e9. Veuillez v\u00e9rifier \u00e0 nouveau votre saisie."}== Info: Connection #0 to host mantis.sfr-ftth.com left intact
obmsch
Posts: 26
Joined: 26 Mar 2013, 22:19

Re: REST API- Summary not specified

Post by obmsch »

At first glance the send data is wrong. All strings are missing qoutes ("). For example summary:summarysample should be
"summary":"summarysample". And after you fixed that, the mandantory 'category' (!) really needs to be "category": {"id": 1}.
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

The quotes are not missing in the actual query:

Code: Select all

curl --trace-ascii - --location --request POST "http://xxxxxxx.xxxxx-xxxxxx.com/api/rest/issues" ^
 --header "xxxxxxxxxxxxxxxxxxxx" ^
 --user "xxxxxxxxxxx:xxxxxxxxxx" ^
 --header "Content-Type:application/json" ^
 --data-raw "{"summary":"summarysample","category":{"id":1,"name":"bugtracker"},"description":"Description","project":{"id":"11","name":"Test"},"custom_fields":[{"field":{"id":"custom_field_10","name":"custom_field_10"},"value":"va"},{"field":{"id":"custom_field_11","name":"custom_field_11"},"value":"00000"},{"field":{"id":"custom_field_12","name":"custom_field_12"},"value":"vav"},{"field":{"id":"custom_field_13","name":"custom_field_13"},"value":"Beton"},{"field":{"id":"custom_field_14","name":"custom_field_14"},"value":"Casse"},{"field":{"id":"custom_field_15","name":"custom_field_15"},"value":"Oui"},{"field":{"id":"custom_field_32","name":"custom_field_32"},"value":"Detendu"},{"field":{"id":"custom_field_16","name":"custom_field_16"},"value":"Facade"},{"field":{"id":"custom_field_23","name":"custom_field_23"},"value":"vpl"},{"field":{"id":"custom_field_24","name":"custom_field_24"},"value":"99"},{"field":{"id":"custom_field_21","name":"custom_field_21"},"value":"Chaussee"},{"field":{"id":"custom_field_22","name":"custom_field_22"},"value":"Cassee"},{"field":{"id":"custom_field_25","name":"custom_field_25"},"value":"var"},{"field":{"id":"custom_field_26","name":"custom_field_26"},"value":"Ouverte"},{"field":{"id":"custom_field_29","name":"custom_field_29"},"value":"Oui"},{"field":{"id":"custom_field_30","name":"custom_field_30"},"value":"Oui"},{"field":{"id":"custom_field_31","name":"custom_field_31"},"value":"vac"},{"field":{"id":"custom_field_27","name":"custom_field_27"},"value":"2.5"},{"field":{"id":"custom_field_28","name":"custom_field_28"},"value":"50.5"},{"field":{"id":"custom_field_17","name":"custom_field_17"},"value":"Collectivite"},{"field":{"id":"custom_field_18","name":"custom_field_18"},"value":"vdn"},{"field":{"id":"custom_field_19","name":"custom_field_19"},"value":"vde"},{"field":{"id":"custom_field_20","name":"custom_field_20"},"value":"0123456789"}]}"
obmsch
Posts: 26
Joined: 26 Mar 2013, 22:19

Re: REST API- Summary not specified

Post by obmsch »

That might be true. But obviously they got stripped of either by the cmdline processing or
by curl itself. That's the reason I escaped all those qoutes in my test. There might be other
means to achieve this, but I guess curl is not the right tool to process such large request anyway.
theo harsant
Posts: 16
Joined: 30 Jan 2020, 15:07

Re: REST API- Summary not specified

Post by theo harsant »

Escaping all the quotes in the data-raw did the trick, thank you very much! I think we can mark this issue as resolved!
Post Reply