Skip to main content

I am working in the Asset workflow automator to create a Purchase order when a consumable inventory is low.  I have been able to create and test every step of my automator successfully except for the webhook to create the purchase order.  I have ended up using the advanced payload so that I could specify different items from a web request to filter assets based on the name and type to get the available quantity data.  I have set the asset type to consumable on creation of the workflow and as such it should have the context of the asset type id available.

This is the basic configuration:

Basic webhook configuration

 

The payload for the body is as follows, utilizing some of the parsed fields to make this as dynamic as possible:

{
"vendor_id": {{P1.root.assets.assets_object.type_fields.vendor_21000057429}},
"name": "Purchase Order for{{P1.root.assets.assets_object.name}}",
"po_number": "AutoPO - {{current_date_and_time}}",
"vendor_details": "string",
"shipping_address": "{{asset.requester.address}}",
"billing_same_as_shipping": true,
"billing_address": "{{asset.requester.address}}",
"currency_code": "USD",
"discount_percentage": 1,
"tax_percentage": 2,
"shipping_cost": 10,
"custom_fields": {},
"purchase_items": s
{
"item_type": {{P1.root.assets.assets_object.display_id}},
"item_name": "{{asset.name}}",
"item_id": {{P1.root.assets.assets_object.id}},
"cost": 0.99,
"quantity": 1,
"tax_percentage": 2
}
]
}

This allows for the proper creation of the Purchase order and testing this body in Postman does create a PO (if I fill in the placeholders).  I have no errors in the execution log, and I have email actions in the automator to track the progress of this.  There is no response code on the webhook at all.  I am wondering if I need a specific automator setup that will expect parameters to be sent in the call and then utilize those parameters to create the PO.

Using a web request does work with the exact same package.

Update to this it turns out that the parsed output from a web request includes brackets and you have no way to strip them out in the automator.

 

This makes for invalid input in my payload:
 

{ 
"vendor_id": :null],
"name": "Purchase Order foro"Dell Monitor"]",
"po_number": "AutoPO - Fri, 24 Jun, 2022 4:12 PM GMT -0400",
"vendor_details": "string",
"shipping_address": "",
"billing_same_as_shipping": true,
"billing_address": "",
"currency_code": "USD",
"discount_percentage": 1,
"tax_percentage": 2,
"shipping_cost": 10,
"custom_fields": {},
"purchase_items": :
{
"item_type": :2],
"item_name": "Dell Monitor",
"item_id": :21000004689],
"cost": 0.99,
"quantity": 1,
"tax_percentage": 2
}
]
}

And at this point my vendor ID is invalid and thus why it fails immediately.


Did you find the answer ?

You wrote you used web requests node and it’s the one you need to use if you wish to get return data. 
This is what Service Desk API for Developers | Freshservice I have found. 


I have been through the API documentation, granted I have missed some things along the way.  What I am looking for is the prebuilt webhooks that are available.  I have tried to use the webhook for PO and completed all of the fields to be passed but it does not create a new PO.  I have no way of seeing what is going on with the webhook and the execution log provides no data what so ever.


Reply