PowerShell Module for FreshService API

  • 21 September 2022
  • 9 replies
  • 265 views

Userlevel 3
Badge +2
  • Top Contributor
  • 11 replies

Having been working with the Freshservice workflow automations with the PowerShell Apps installed, I’ve created PowerShell modules to manage Fresh Service, currently covering tickets, requesters, agents, groups, service catalog items, custom objects, locations and departments.

You can find the module here on GitHub: LesNewbigging/FreshAPIv2: A PowerShell module containing functions that invoke the Fresh v2 APIs (github.com)

This is a work in progress, and I intend to add more functionality for other areas the API covers, but I prioritised on the assumption that tickets would be the main focus of any interaction.

Feel free to take the code and adapt it for your own needs - I’ve tried to make them as generic as possible, wrapping the API functionality within them.

Comments and suggestions are welcome.


9 replies

Userlevel 7
Badge +14

Wow @LNew what a great contribution!!!! I would encourage you to share this with the Developer Community as well here. This is in the true spirit of Open Source and is much appreciated! Keep up the great work 😎

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

Userlevel 3
Badge +2

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

Hello Joshua
Group isn’t mandatory for me, so I presume it is something set by your organisation. I have created tickets with and without the group using my module.

Is the Group ID you are using an Agent group, rather than a Requester group? 
Adding the -Verbose option will show the body payload, which may assist in troubleshooting.

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

I presumed it was “group_id” rather than just “group”...

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

I presumed it was “group_id” rather than just “group”...

Powershell autofills -Group , but I believe you can use either “Group” or “GroupID”. I put both -Group and -GroupID and it said that it was “specified more than once”. I tried each one by itself and they both threw that group is mandatory 

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

Hello Joshua
Group isn’t mandatory for me, so I presume it is something set by your organisation. I have created tickets with and without the group using my module.

Is the Group ID you are using an Agent group, rather than a Requester group? 
Adding the -Verbose option will show the body payload, which may assist in troubleshooting.

Yea, group is mandatory for our organization. I’m using Group IDs from: https://support.xxxxxx.com/groups/2000017xxxx/edit

-Group “2000017xxxx”

Userlevel 3
Badge +2

@LNew I keep running into an issue creating a new ticket. It’s telling me that I’m missing the mandatory “group” field. However, I am using that and what looks to be all the mandatory fields.

Any thoughts?

Hello Joshua
Group isn’t mandatory for me, so I presume it is something set by your organisation. I have created tickets with and without the group using my module.

Is the Group ID you are using an Agent group, rather than a Requester group? 
Adding the -Verbose option will show the body payload, which may assist in troubleshooting.

Yea, group is mandatory for our organization. I’m using Group IDs from: https://support.xxxxxx.com/groups/2000017xxxx/edit

-Group “2000017xxxx”

That seems anout right, but you can double-check the id using Get-FreshAgentGroup.
Using -Verbose will show the body of the request, This should look something like this:
{
    "source":  2,
    "description":  "My engine has broken",
    "category":  "Hardware",
    "urgency":  1,
    "group_id":  27000099999,
    "subject":  "My engine is broken",
    "impact":  1,
    "status":  2,
    "priority":  1,
    "email":  "virgil@tracey-island.org"
}

 

Hi LNew,

First of all this is AWESOME work you have put in these modules. I was just about to write my own, until I came across yours. Really well done!

But…. I think I found a minor issue in FreshAPI.Tickets.psm1. For the function New-FreshTicketReply and the function function New-FreshTicketNote you are currently using the same URL sub folder, shouldn’t these be different from each other?

On line number 2521 (in the reply function) the path ends with reply

Invoke-FreshAPIPost -path "tickets/$TicketID/reply"

 

On line number 2614 (in the note function) the path also ends with reply

Invoke-FreshAPIPost -path "tickets/$TicketID/reply"

 

When I was fiddling around with adding notes (before I found your mods), I used the /notes path so I think the line on 2614 so actually read:

Invoke-FreshAPIPost -path "tickets/$TicketID/notes

 

Or are these paths interchangeable and thus give the same results?

Regards,

Erik

Userlevel 3
Badge +2

Thanks Erik

I’m glad you’re finding it useful, and thanks for that spot!

The paths aren’t really interchangeable. To summarise:

Replies:

  • add a note to the conversation
  • send an email to the requester (and CCs) exactly as it is entered
  • cannot be edited at a later date

Whereas notes:

  • add a note to the conversation
  • cause a notification to be sent to the requester to say a note has been added, including the content (except for private notes)
  • can be edited at a later date

I’ve updated the module and pushed it to GitHub again, though it looks like you’ve already updated your module already.

Are there any other features you’d like included? At work I’m looking at the inventory, so have been working with asset, contract, software and product functions, so I’ll be looking to include genericised versions of those at some point. But I’m happy to look at any other features.

Thanks again Erik for that spot - much appreciated! And if you spot anything else, let me know.

Les

Reply