403 Response Error when using REST API

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
jcordes74
Posts: 8
Joined: 24 Jun 2022, 20:01

403 Response Error when using REST API

Post by jcordes74 »

Hello all, I'm getting a 403 response error and I have no idea why. I should have access to everything on the site, as far as I know. Here is my block of code:
I replaced some sensitive variable names with (x)

import requests
import json
import getpass

url = 'http:// (x) /api/rest/issues'
#####Attempting to post data to this url

username = getpass.getuser()
password = getpass.getpass(prompt="Enter (user %s)'s password on %s: " % (username, ' (x) '))

headers = {
"Content-Type": "application/json",
"Authorization": " (x) " <--- I put my api token here
}

post_data = {
"summary": "Sample REST issue",
"description": "Description for sample REST issue.",
"additional_information": "More info about the issue",
"project": {
"name": " (x) "
},
"category": {
"name": "ASIC"
},
"handler": {
"name": " (x) "
},
"view_state": {
"name": "public"
},
"priority": {
"name": "normal"
},
"severity": {
"name": "trivial"
},
"reproducibility": {
"name": "always"
}
}


post_response = requests.post(url = url, headers = headers, json = post_data, auth = (username,password))
print(post_response) 6,1
Post Reply