pluginsGLPI / formcreator

GLPI Plugin Formcreator (DOWNLOAD : https://github.com/pluginsGLPI/formcreator/releases)
http://www.teclib-edition.com
GNU General Public License v3.0
174 stars 125 forks source link

Insert question into Form via Api apirest.php/PluginFormcreatorQuestion #3418

Open blackmagic42 opened 1 year ago

blackmagic42 commented 1 year ago

Hello I'm trying to insert questions into form with the Api But i got this error because i don't have the good parameters "ERROR_GLPI_ADD","Vous n\'avez pas les droits requis pour r\xc3\xa9aliser cette action."

This is my code

`import requests import json

def add_form_question(session_token,id,name,description,port):

data = json.dumps(
{   "input": {
        "items_id": id,
        "itemtype": "",
        "entities_id": 1,
        "row": 3,
        "col": 1,
        "width": 5,
        "show_rule": 1,
        "name": name,
        "is_recursive": 0,
        "required": 0,
        "fieldtype": "textarea",
        "description": description,
        "values": None,
        "uuid": None,
        "required": 0,
        "show_empty": 0,
        "default_values": '',
        'links': {},
        "_parameters[textarea][regex][regex]": "",
        "_parameters[textarea][range][range_min]": 0,
        "_parameters[textarea][range][range_max]": 0,
        "_conditions[show_logic][]": 1,
        "_conditions[plugin_formcreator_questions_id][]": 24, #don"t worry it's the good id because i have done it with burp 
        "_conditions[show_value][]": port,
    }
})
response = requests.post(f"XXXXXX/apirest.php/PluginFormcreatorQuestion/{id}", #don't worry i got the good url in my code
    headers={
        "Content-Type": "application/json",
        "Session-Token": session_token,
        "App-Token": "XXXXXX", #don't worry i have put my app token here 
    },
    data=data
)
if response.status_code == 200 or response.status_code == 206:
    data = response.json()
    print(data)
    return data
else:
    print(response.content)
    raise Exception(f"Erreur lors de l'ajout d'un ordinateur : {response.status_code}")

`

btry commented 12 months ago

Hi

It seems you did not specified in which section the question is inserted. Try again by setting the parent section in the request.