View Issue Details

IDProjectCategoryView StatusLast Update
0026625mantisbtapi restpublic2020-01-24 15:21
Reportervolawe9575 Assigned To 
PrioritynormalSeveritymajorReproducibilityhave not tried
Status newResolutionopen 
Product Version2.22.2 
Summary0026625: Id must be numeric
Description

Hi,
i am trying to automate some work on mantis, but for some reason api refuses to accept id(int/string). What am I doing here wrong?

Steps To Reproduce

$ItsmHost = 'xxxxxxxxxxxxx'
$TechKey = "xxxxxxxxxxxxxxx"

$RequestListByFilter =
@{
"uri"= $ItsmHost
"Authorization"= $TechKey
}

$Header =
@{
"Authorization" = $TechKey
"ContentType" = "Content-Type: application/json"
}

$CreateNote=@"
{
"text": "Przejeto",
"view_state": {
"name": "public"
}
}
"@

$url = $ItsmHost

$GET_REQUESTS_PARAMS = @{OPERATION_NAME='ISSUES';INPUT_DATA=$RequestListByFilter;format = "json"}
    $GET_REQUESTS_RESPONSE =  Invoke-RestMethod -Uri $url -Method GET -Body $GET_REQUESTS_PARAMS -Headers $RequestListByFilter
    $IssueID = $GET_REQUESTS_RESPONSE.issues.id

##$NoteHost = 'xxxxxxxxxxxxxxxxx/api/rest/issues/:' + $IssueID + '/notes'

function CreateNote
{
Param ([int]$ID)
$NoteHost = 'xxxxxxxxxxxx/api/rest/issues/' + $id + '/notes'
$CreateNoteParams = @{OPERATION_NAME='MESSAGE';INPUT_DATA=$CreateNote;format = "json"}
$CreateNote = Invoke-RestMethod -uri $NoteHost -Method POST -Body $CreateNoteParams -Headers $Header

}

foreach ($element in $IssueID) {
CreateNote($element)
}

Additional Information

Error:
Invoke-RestMethod : {"message":"'issue_id' must be numeric","code":29,"localized":"Nieprawid\u0142owa warto\u015b\u0107 dla 'issue_id'"}
At line:44 char:23

  • ... reateNote = Invoke-RestMethod -uri $NoteHost -Method POST -Body $Crea ...
  • 
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    Invoke-RestMethod : {"message":"'issue_id' must be numeric","code":29,"localized":"Nieprawid\u0142owa warto\u015b\u0107 dla 'issue_id'"}
    At line:44 char:23
  • ... reateNote = Invoke-RestMethod -uri $NoteHost -Method POST -Body $Crea ...
  • 
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-01-24 15:21 volawe9575 New Issue