1

I'm trying to create a new defect with powershell.

I can connect to the api and even get the list of all defects or by id.

I'm now trying to create a defect but without success.

Indeed, i'm sending a json but i'm only getting a "missing required field: description for entity defect"

here is my powershell

$data = @{
description="dsfdsfsdffsdf"
"detected-by"="myuser"
"priority"="N/A"
owner="myuser"
"severity"="Minor"
status="Open"
name="test"
"user-04"="myproject"
"user-07"="Delivery"
"user-08"="Dummy1"
"user-09"="Acceptance"
"user-11"="01"
"user-22"="eaz"
"detected-in-rcyc"="1367"
}

$JSON = $data |ConvertTo-Json

write-host $JSON

$url = "http://****:8080/qcbin/rest/domains/mydomain/projects/myproject/defects/"
$result = Invoke-RestMethod -Method Post -Uri $url -WebSession $websession -Body $JSON -ContentType "application/json"

And the error :

Invoke-RestMethod : 
Missing required field: description for entity defect
    HPE Application Lifecycle Management
    Missing required field: description for entity defect
            Exception Id:
            qccore.required-field-missing
        Show Details
            Exception Properties:
            field-name: description
entity-name: defect
            Stack Trace:

Thank you for your help.

Friedrich Dylan
  • 114
  • 1
  • 11
  • 1
    Do you have any documentation for this API? I might be able to help but I am not familiar with it. – Persistent13 Mar 14 '19 at 14:43
  • Hello, yes thank you.you can check the "create an instance". here is the link. https://admhelp.microfocus.com/alm/en/12.60/api_refs/REST/Default.htm#REST_API/How_To.htm%3FTocPath%3DWorking%2520with%2520the%2520API%7CHow%2520Do%2520I...%7C_____0 – Friedrich Dylan Mar 14 '19 at 14:47
  • Looks like you are missing a `"type" = "defect"` in your data – Theo Mar 14 '19 at 15:40
  • Hello #Theo. I tried but without success. Even if i try to update an existing one, i got a no field are specified ( and i'm only trying to change the name). this must be an issue with my json but i don't know why. – Friedrich Dylan Mar 15 '19 at 07:42
  • according to the docs, you provided - you have to put your fields into "data" object. Check out an example: https://admhelp.microfocus.com/alm/en/12.60/api_refs/REST/Default.htm#REST_API/Create_an_Instance.htm%3FTocPath%3DWorking%2520with%2520the%2520API%7CHow%2520Do%2520I...%7C_____2 – Sergi Mar 15 '19 at 14:20

0 Answers0