Question

unable to create ticket with api v2 with python or postman

  • 11 August 2021
  • 1 reply
  • 820 views

I am trying to create tickets using postman or python , but i get back this error as follows

{
    "code""access_denied",
    "message""You are not authorized to perform this action."
}
 
from http.client import HTTPSConnection
import json
from base64 import b64encode
#This sets up the https connection
c = HTTPSConnection("midwichhelpdesk.freshservice.com")
#we need to base 64 encode it
#and then decode it to acsii as python 3 stores it as a byte string
userAndPass = b64encode(b"tazeen_86@hotmail.com:Tazeen86!").decode("ascii")
headers = {"Content-type": "application/json",
"Accept": "application/json", 'Authorization' : 'Basic %s' % userAndPass }
data={
"name" : "Taz",
"requester_id":1,
"email": "tazeen_86@hotmail.com",
"phone":"+61452418384",
"status":2,
"priority":3,
"source":1
}
json_data = json.dumps(data)
#then connect
c.request('POST', '/api/v2/tickets',json_data, headers=headers)
#get the response back
res = c.getresponse()
# at this point you could check the status etc
# this gets the page text
data = res.read()

print(data)

 


1 reply

Userlevel 5
Badge +12

Hello @tazeen_86, apologies for not getting back to you sooner on this. As far as we’ve seen, the error would be thrown when you have insufficient previleges to perform an action.

Can you try using the account admin API key with password as X and see if that helps? If the issue persists, can you share a request ID of the call that’s failing so that we can have a look at it in the backend?

Reply