You are not logged in.
When using the python method below to add a file as a follow-up I get a status 400 saying that I don't have permission to do this, however, in the administrative panel my user's profile type has authorization to add/change follow-ups, how to solve this?
def create_new_followup_file_service(
self,
message: Message,
ticket_id: str,
name,
filepath,
):
_UPLOAD_MANIFEST = (
'{{ "input": {{ "name": "{name:s}", "_filename" : ["{filename:s}"] }} }}'
)
with open(filepath, "rb") as fhandler:
try:
response: Response = requests.post(
url=f"{URL}/Document",
headers=self._get_headers(message),
files={
"uploadManifest": (
None,
_UPLOAD_MANIFEST.format(
name=name,
filename=os.path.basename(filepath),
),
"application/json",
),
"filename[0]": (filepath, fhandler),
},
verify=config("VERIFY_SSL"),
)
if response.status_code == 201:
glpi_response: Dict = json.loads(response.content.decode("utf-8"))
uploadManifest = {
"input": {
"itemtype": "Ticket",
"items_id": 202658,
"documents_id": glpi_response["id"],
}
}
response = requests.post(
f"{URL}/Ticket/202658/Document_Item",
headers=self._get_headers(message),
data=json.dumps(uploadManifest),
verify=config("VERIFY_SSL"),
)
print(response)
return response
except Exception as error:
print(error)
Response:
status 400
content: b'["ERROR_GLPI_ADD","Voc\xc3\xaa n\xc3\xa3o tem permiss\xc3\xa3o para executar essa a\xc3\xa7\xc3\xa3o."]'
reason: bad request
text: '["ERROR_GLPI_ADD","Você não tem permissão para executar essa ação."]'
Offline