View Issue Details

IDProjectCategoryView StatusLast Update
0026121mantisbtapi restpublic2019-12-02 17:13
Reportereaaswrm Assigned Todregad  
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionno change required 
Product Version2.22.0 
Summary0026121: Problem creating issues with custom fields using REST API
Description

I'm trying to create new issues using Mantis REST API but I'm getting a problem with custom fields, I'm following guidlines from Postman and sending that data in json:

{
    'summary': 'Test_summary', 
    'project': {'id': '123'}, 
    'custom_fields': [
        {
        'field': {'name': 'IP name'}
        'value': 'Test', 
        }, 
        {
        'field': {'name': 'Other'}}
        'value': 'MISC', 
        ], 
    'description': 'Test_summary', 
    'category': {'name': 'RnD Env'}
}

But I'm getting answer back that custom field is empty:

"Invalid custom field 'IP name' value.","code":11,"localized":"A necessary field \"IP name\" was empty. Please recheck your inputs."

Mantis v. 2.22 but same problem was present in previous install v 2.14

EDIT [dregad] Markdown block quote

TagsNo tags attached.

Activities

dregad

dregad

2019-09-09 10:49

developer   ~0062755

It works for me.

Are you really using single quotes ? If so, please try again with double quotes, as per JSON specification

A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes.

dregad

dregad

2019-09-09 10:51

developer   ~0062756

Last edited: 2019-09-09 11:02

Also, there seems to be a misplaced }

        'field': {'name': 'Other'}}
        'value': 'MISC', 

should probably be

        'field': {'name': 'Other'}
        'value': 'MISC'}, 

EDIT: And missing comma after "field": {"name": "xxx"}

Make sure you use valid JSON http://json.parser.online.fr/

eaaswrm

eaaswrm

2019-09-12 10:04

reporter   ~0062777

Last edited: 2019-09-12 10:08

It looks to be a typo. I'm using Python script to generate that data for me and it uses good JSON encoding (with double quotes). This is the data that is being sent (checked with suggested JSON parser):

<code>
{
"summary": "Test_summary",
"category":
{"name": "RnD Env"},
"project":
{"id": "123"},
"custom_fields":
[
{"field":
{
"id": 69,
"name": "Tool Selection"
},
"value": "Other"}
],
"description": "Test_summary"
}
</code>

dregad

dregad

2019-09-12 19:32

developer   ~0062786

And with this, you get the same error message as previously mentioned, but for Tool Selection instead if IP name custom field ?
What does the definition for that custom field look like ? Does it indeed have id = 69 ? Is Other a valid value for it ?

eaaswrm

eaaswrm

2019-09-17 05:02

reporter   ~0062836

Last edited: 2019-11-02 06:56

Yes, I get the same error (IP name is no longer required).

 {
          "id": 69,
          "name": "Tool Selection",
          "type": "list",
          "default_value": "",
          "possible_values": "ToolA | ToolB | ... | Other",
          "valid_regexp": "",
          "length_min": 0,
          "length_max": 0,
          "access_level_r": {
            "id": 25,
            "name": "reporter",
            "label": "reporter"
          },
          "access_level_rw": {
            "id": 25,
            "name": "reporter",
            "label": "reporter"
          },
          "display_report": true,
          "display_update": true,
          "display_resolved": false,
          "display_closed": false,
          "require_report": true,
          "require_update": false,
          "require_resolved": false,
          "require_closed": false
        },
eaaswrm

eaaswrm

2019-09-26 11:07

reporter   ~0062916

@dregad, do you have any idea what I could try next?

dregad

dregad

2019-11-02 06:59

developer   ~0063049

Sorry for the delayed response.

do you have any idea what I could try next?

No I don't. Especially considering that you have not provided information regarding the CF's definition.

atrol

atrol

2019-11-17 08:49

developer   ~0063109

eaaswrm,

You did not provide feedback; I am therefore resolving this issue as "no change required".

Feel free to reopen the issue at a later time and provide the requested information.

wilfried2006

wilfried2006

2019-11-18 08:10

reporter   ~0063110

it doesnt work. Lets try something else.