View Issue Details

IDProjectCategoryView StatusLast Update
0027105mantisbtapi restpublic2021-02-20 12:16
Reporteralexandre.fournel@sia-partners.com Assigned Todregad  
PriorityhighSeverityfeatureReproducibilityalways
Status closedResolutionunable to reproduce 
Product Version2.24.1 
Summary0027105: change handler api rest python
Description

Hi all !
I can't manage to change handler of one of my issue (number 5) by using API written on postman Website.
Someone can help ?

This is my code :

url_issue = "http://XXX.XXX.X.XX/mantisbt/api/rest/issues/5"
token='XXXXXXXXXXXXXXXXXXXXXXX'
payload = "{  \"id\": 5,  
                       \"handler\ : {\"id\":9, \"name\":\"Codix\",  \"real_name\":\"Codix\", \"email\":\"alexandre.fournel@ensta-paris.fr\"}
                    }"

Thanks a lot !

TagsNo tags attached.

Activities

alexandre.fournel@sia-partners.com

alexandre.fournel@sia-partners.com

2020-07-24 03:31

reporter   ~0064181

Last edited: 2021-02-10 09:37

I forgot some lines :

headers = {
        'Authorization': token,
        'Content-Type': 'application/json'
    }
    response = requests.request("PATCH", url_issue, headers=headers, data = payload)
    print(response.text.encode('utf8'))
dregad

dregad

2021-02-10 09:56

developer   ~0065094

Works for me.

Note that with the Python requests API, you should pass a JSON string in the data parameter, or use the json parameter and give it a dictionary.
Also, you don't need to provide the handler's details - just the name or the id is enough.

payload = '''{"handler": {"name": "Codix"}}'''
response = requests.patch(url_issue, headers=headers, data=payload)

or

payload = {"handler": {"name": "Codix"}}
response = requests.patch(url_issue, headers=headers, json=payload)
response = requests.patch(url_issue, headers=headers, data=json.dumps(payload))