API Create Ticket - "The type provided for the ticket does not exist or is invalid."

I'm having some issues getting the API to work to create a new ticket. Every time I try I just get the error:

{"ID":-1,"Message":"The type provided for the ticket: id: 0 APP:2885 does not exist or is invalid."}

I'm definitely passing a TypeID that is valid into the API call, so I'm not sure what I'm missing here. I've tried all sorts of formatting changes (with quotes, without quotes, changing the order of the variables passes, etc.), but nothing seems to help.

Here's what my code is looking like, trying to use curl on a linux box to make the API call. I redacted our subdomain, and also we're trying to test doing this with the Sandbox, but I did also try it with the production URL with the same effect.

# Set API BEID and Web Services Key

BEID="[REDACTED]"

webServicesKey="[REDACTED]"

 

# Set the API URL

url="https://redacted.teamdynamix.com/SBTDWebApi"

 

# Get the jwt token (this works correctly)

jwt=$(curl -X POST -H "Content-Type: application/json; charset=utf-8"\

  -d "{'BEID': '$BEID', 'WebServicesKey': '$webServicesKey'}" \

  $url/api/auth/loginadmin)

 

# Get a test ticket - (this works correctly, just have it commented out)

# curl -X GET -H "Authorization: Bearer $jwt" \

#   $url/api/tickets/19440924

 

# Create a new ticket (2885 is the correct Application ID for our instance)

curl -X POST -H "Authorization: Bearer $jwt" \

  -d "{

      'TypeID': 40257,

      'Title': 'Test API Ticket',

      'Description': 'This is a ticket made by API call',

      'TypeCategoryID': 6815,

      'Classification': 34,

      'AccountID': '103904',

      'RequestorUid': 'ffa14dc3-35ba-eb11-a7ad-dc98408d7262',

      'StatusID': 134647,

      'PriorityID': 6659

      }" \

  "$url/api/2885/tickets?EnableNotifyReviewer=False&NotifyRequestor=False&NotifyResponsible=True&AllowRequestorCreation=False"

Interestingly, even if I change the AppID in the URL, it still spits out the same error message with the 2885 AppID.

Tags API
Asked by Austin Wolcott on Fri 7/22/22 5:13 PM
Sign In to leave feedback or contribute an answer

Answers (2)

This answer has been marked as the accepted answer
Austin Wolcott Mon 7/25/22 10:09 AM

I figured out what the issue was. I didn't have a second header line defining the Content-Type. I needed to edit my call to look like this:
 

curl -X POST \

  -H "Authorization: Bearer $jwt" \

  -H "Content-Type: application/json; charset=utf-8" \

  -d "{

      'TypeID': 40257,

      'Title': 'Test API Ticket',

      'Description': 'This is a ticket made by API call',

      'TypeCategoryID': 6815,

      'Classification': 34,

      'AccountID': '103904',

      'RequestorUid': 'ffa14dc3-35ba-eb11-a7ad-dc98408d7262',

      'StatusID': 134647,

      'PriorityID': 6659

      }" \

  $url/api/2885/tickets?EnableNotifyReviewer=False&NotifyRequestor=False&NotifyResponsible=True&AllowRequestorCreation=False

 

Also for what it's worth, it did actually work with both the TDX user and the admin API.

No feedback
Some endpoints *will* work with both types of logins (admin and normal) but not all endpoints that do not specify the need for the admin account will work with that account. So that is something to be aware of. - Mark Sayers Mon 7/25/22 10:24 AM

Mark Sayers Mon 7/25/22 9:27 AM

Hello Austin,

I'm not 100% positive the Admin login can successfully call the ticket creation endpoint. Have you tested it with a "regular" user account, or else a Service Account that was created from within TDAdmin > Users & Roles > Users?

Sincerely,
Mark Sayers
Sr Support Consultant, CS

No feedback
I did try it with a user account, as well. I created a user in TDAdmin > Users & Roles > User, and gave it full access rights to the ticketing application, and it gets the same result. - Austin Wolcott Mon 7/25/22 9:43 AM