Skip to content

New-FSChange Invoke-Webrequest The remote server returned an error: (400) Bad Request #28

Description

@MikeBakerSAV

Expected Behaviour

New-FSChange -subject "Test Change Control" -description "This is the description and it will go on and on and on" -status 2 -priority 2 -impact 2 -risk 2 -category "a category" -sub_category "Email" -planned_start_date "2025-02-06" -planned_end_date "2025-02-07" -requester_id "xxyyxxaaaaxx"

change is created

Current Behaviour

Creating changes in bulk from other systems; running manually the ps :

New-FSChange -subject "Test Change Control" -description "This is the description and it will go on and on and on" -status 2 -priority 2 -impact 2 -risk 2 -category "a category" -sub_category "Email" -planned_start_date "2025-02-06" -planned_end_date "2025-02-07" -requester_id "xxyyxxaaaaxx"

VERBOSE: Invoke-FreshworksRestMethod - Body: {
"category": "Collaboration Services",
"description": "This is the description and it will go on and on and on",
"risk": 2,
"planned_end_date": "2025-02-07T00:00:00Z",
"impact": 2,
"sub_category": "Email",
"planned_start_date": "2025-02-06T00:00:00Z",
"subject": "Test Change Control",
"workspace_id": 1,
"status": 2,
"priority": 2,
"requester_id": xxyyxxaaaaxx
}
VERBOSE: Invoke-FreshworksRestMethod - ErrorAction: Stop
VERBOSE: Invoke-FreshworksRestMethod - Invoking REST POST Method on
https://xyz.freshservice.com/api/v2/changes...
VERBOSE: Invoke-FreshworksRestMethod - Forcing TLS 1.2 protocol for invoking REST method.
VERBOSE: POST https://xyz.freshservice.com/api/v2/changes with -1-byte payload
VERBOSE: Catching exception System.Net.WebException with status code
VERBOSE: Throwing Default exception of type System.Net.WebException

Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At C:.......\Documents\WindowsPowerShell\Modules\FreshservicePS\0.1.6\Private\Invoke-FreshworksRestMethod.ps1:191 char:28

  •             $results = Invoke-WebRequest @restParams
    
  •                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExceptio
      n
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions