Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-FreshserviceContract attachments not working #12

Open
rasimmers opened this issue Oct 16, 2023 · 0 comments
Open

New-FreshserviceContract attachments not working #12

rasimmers opened this issue Oct 16, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rasimmers
Copy link
Contributor

rasimmers commented Oct 16, 2023

Expected Behavior

New-FreshserviceContract will create a Contract with specified attachment(s).

Current Behavior

Error message from API:

| {"description":"Validation failed","errors":[{"field":"auto_renew","message":"It should be of type
| Boolean","code":"datatype_mismatch"},{"field":"notify_expiry","message":"It should be of type
| Boolean","code":"datatype_mismatch"},{"field":"notify_to","message":"It should be in the 'valid email
| address' format","code":"invalid_value","nested_field":"notify_to.[0]"}]}

Appears to be an issue with data being passed as multipart/form-data.

Possible Solution

As a workaround, create Contract without attachment(s) and then use Set-FreshServiceContract to attach items.

Steps to Reproduce (for bugs)

  1. Create a new Contract and specify the path to a file with -attachments:
$icd = New-FreshServiceContractItem -item_name License -pricing_model per_unit -cost 18.44 -count 350 -comments 'Per user licensing costs'

$contractParams = @{
    # id                 = 6
    name               = 'Microsoft O365 Contract V2'
    description        = 'Test contract from API'
    vendor_id          = 21000085375 #Get-FreshServiceVendor
    auto_renew         = $true
    notify_expiry      = $true
    notify_before      = 30
    approver_id        = 21000418005 #Get-FSRequester
    start_date         = Get-Date
    end_date           = (Get-Date).AddDays(365)
    cost               = 6454.00
    contract_number    = 'MSFT11'
    contract_type_id   = 1
    visible_to_id      = 21000188401 #Get-FSAgentGroup
    notify_to          = '[email protected]'
    #software_id        = 21000240240 #Get-FSSoftware
    #billing_cycle      = 'annual'
    # item_cost_details  = @($icd)
    # item_cost_details  = @([pscustomobject]@{item_name='Installation'; pricing_model='per_unit'; cost=200; count=1})
     attachments        = 'C:\Scripts\Contract.txt'
     associated_asset_ids = @(1)
}

New-FreshserviceContract @contractParams -Verbose
  1. Execute command and API produces:
| {"description":"Validation failed","errors":[{"field":"auto_renew","message":"It should be of type
| Boolean","code":"datatype_mismatch"},{"field":"notify_expiry","message":"It should be of type
| Boolean","code":"datatype_mismatch"},{"field":"notify_to","message":"It should be in the 'valid email
| address' format","code":"invalid_value","nested_field":"notify_to.[0]"}]}

If the attachment is removed, the code executes successfully.

Context

Cannot create Freshservice Contract with attachments.

Your Environment

  • Module version used: 0.1.4
  • Operating System and PowerShell version: Windows 11 with Powershell 7.3.4
@rasimmers rasimmers self-assigned this Oct 16, 2023
@rasimmers rasimmers added the bug Something isn't working label Oct 16, 2023
@rasimmers rasimmers changed the title New-FreshserviceContractItem attachments not working New-FreshserviceContract attachments not working Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant