Skip to main content

I’m new to trying to use the API.

I’m trying to create a new ticket once some action is taken on an existing ticket.  In my case when we offboard someone, after they have been offboarded I need to file tickets and assign to different business owners so they can remove the user from their systems.

I created a Web Request as follows:

Request Type: Post

Endpoint: https://domain.freshservice.com/api/v2/tickets

Credentials: Inline Credentials

Authentication Type: Basic Auth

Username: my API Key

Password: X  (thank you @zachary.king for posting that in multiple topics)

Body: 

{
  "description": "Details about the issue...",
  "subject": "Support Needed...",
  "source": 2,
  "email": "myemail@mydomain.com",
  "priority": 1,
  "status": 2,
  "group_id": 999999999999,
  "System": "Salesforce"
}

 

The issue I have is System is a required ticket field.  If I don’t include it in the body I get an error stating :

{
  "description": "Validation failed",
  "errors": d
    {
      "field": "system",
      "message": "It should be one of these values: 'Help Desk,Salesforce,Dialpad'",
      "code": "missing_field"
    }
  ]
}

If I do include it as above in the Body I get an error:

{
  "description": "Validation failed",
  "errors": V
    {
      "field": "System",
      "message": "Unexpected/invalid field in request",
      "code": "invalid_field"
    }
  ]
}

Not sure what I’m doing wrong that it sees it required but doesn’t like what I’m typing in, so is it some type of encoding error?

Hey Patrick, 

Are you using the Offboarding module? It would be alot simpler! :D 


@Roxwell  No, the Onboarding and Offboarding modules do not meet my needs.  We have a complicated structure built, maybe one day we can but today we can’t use those modules.

Today during offboarding we create about 12 tasks that I manually run through for a variety of items like turning off the account and access, to shipping a return box/label, to receiving the device back, to deleting their account in 30 days.  The offboarding to create tickets vs tasks doesn’t work for me.

 

For this during offboarding I have to manually look at what AD security groups a user is a member of and then contact each business owner for what a user has access to so they can go into their applications and remove the user.  Yes, I can automate removing them from the group to break SSO logins but the business owner still needs to take action within their applications.  Most business owners are not Agents in our freshservice but 1 group is so I want to assign them a ticket after someone has been offboarded.  I can’t tell them ahead of time.


Ah, see what I would do, is use Offboarding, have a workflow that adds the tasks to the offboarding ticket for you to do your tasks. 

Then I would have a workflow, that emails the requisite Business owners, when the appropriate task is complete. 

The one group that is an agent, can then receive a ticket from offboarding, and set it as a successor ticket of your offboarding ticket. 


Hey @PatrickMurphy, is “System” a custom field? If so then you need to nest the field in the “custom_fields” property within the body of your request. Something like this:

{
  "description": "Details about the issue...",
  "subject": "Support Needed...",
  "source": 2,
  "email": "myemail@mydomain.com",
  "priority": 1,
  "status": 2,
  "group_id": 999999999999,

  “custom_fields”: {
      "System": "Salesforce"

  }
}

I think this should fix the issue.

Take care!


No go.  

Now I get the every field is error message on 405

{
  "description": "Validation failed",
  "errors": s
    {
      "field": "description",
      "message": "This field cannot be empty",
      "code": "missing_field"
    },
    {
      "field": "status",
      "message": "It should be one of these values: '2,3,4,5,6,7,8'",
      "code": "missing_field"
    },
    {
      "field": "subject",
      "message": "It should be of type String",
      "code": "missing_field"
    },

 

I’ve tried moving the custom field statement around in the system but doesn’t seem to make a difference.  I’ll keep researching.


No go.  

Now I get the every field is error message on 405

{
  "description": "Validation failed",
  "errors": s
    {
      "field": "description",
      "message": "This field cannot be empty",
      "code": "missing_field"
    },
    {
      "field": "status",
      "message": "It should be one of these values: '2,3,4,5,6,7,8'",
      "code": "missing_field"
    },
    {
      "field": "subject",
      "message": "It should be of type String",
      "code": "missing_field"
    },

 

I’ve tried moving the custom field statement around in the system but doesn’t seem to make a difference.  I’ll keep researching.

Interesting, can you share the exact JSON you are sending in the body? Minus any sensitive data of course.

Here is an example that works when I send it off

Another way to verify you are sending the correct data is to use a GET request to get the contents of a ticket where your “Systems” field has a value, this will show you how it expects to accept the field in the body of your POST request. I would try using a tool like Postman to make your requests, this will give you more context and make it easier to make adjustments. Especially around indicating any issues with how your JSON data is formatted. Hope that helps.


I probably set you up for failure by using “System” and not “system”. JSON payload data is going to be “snake_case”. That maybe be the issue.


Try this

{
"description": "Details about the issue...",
"subject": "Support Needed...",
"source": 2,
"email": "myemail@mydomain.com",
"priority": 1,
"status": 2,
"group_id": 999999999999,
"custom_fields": {
"system": "Salesforce"
}
}

 


So the issue was some white space (hidden character). I back spaced all the characters and put spaces where necessary. 

I’ve got it to work now in ticket automation.

Trying to get it to work in Task Automation , but getting an Invalid Host error.  Should you be able to call the same web request module from a Ticket or Task workflow?


So the issue was some white space (hidden character). I back spaced all the characters and put spaces where necessary. 

I’ve got it to work now in ticket automation.

Trying to get it to work in Task Automation , but getting an Invalid Host error.  Should you be able to call the same web request module from a Ticket or Task workflow?

Yes you should be able to create a Web Request from a Task workflow automator. The function the same. You will see some subtle difference in the data available based on what you select as the “Parent Entity” when you first create the Task workflow.