This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Powershell rest api update custom field

Hi

I am battling to get to grips with the rest api.

I am using the below PowerShell script which does not throw any exceptions

can anybody shed some light on my dilemma

The full story:  { I am using powershell to identify status changes in Web help Desk database, and create issues in JIRA for my KANBAN board ( Via the rest api) the response from Jira is the issue number Just created,

I now want to update Web Help Desk "ticket custom field"   with this JIRA ticket Number.}

any help appreciated

Thanks

$definitionId = "33"

$restValue = "E1245"

$uri = 10.5.67.159/.../


$body = @{

  definitionId=$definitionId

  restValue=$restValue

   $jsonBody = ConvertTo-Json $body

   $resp =  Invoke-RestMethod -uri $uri -Method Put -body $jsonBody -ContentType "application/json" 

     $cat = $resp.id

    write-host " key = $resp.id"

------------------------

after execution returns The Id of the ticket as expected, but no update happens


I get the info I deem necessary from this command line in chrome, I also use to inspect if my update has worked


103.52.67.159/.../


which returns details of the ticket to viewing pane  Ticket id = 36566

{"id":36566,"type":"Ticket","bccAddresses":null,"ccAddressesForTech":null,"departmentId":null,"lastUpdated":"2014-11.................":"TicketCustomField","definitionId":31,"restValue":"23333"},{"id":15947,"type":"TicketCustomField","definitionId":32,"restValue":"Accounting / Financials"},{"id":18080,"type":"TicketCustomField","definitionId":33,"restValue":"233332"},{"id":

  • Ha! Battling is the term to use with the rest api that's for sure!

    We do exactly what you're trying to do with our custom written Job management program.

    The relevant bits from my post on this (API integration with WHD) for your question are:

    --snip--

    We also wanted to be able to update the ticket custom field with the new job number from our system (you can see the ticket number I was experimenting with was 115 and the json file containing the new field value is called test.json)

    Invoke-RestMethod "http://helpdeskURL/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets/115?&apiKey=keygeneratedundertechaccount" -InFile test.json -Method Put


    Contents of the test.json file looks like this (custom field ID is 13, Job number to be inserted E12345)

    {"customFields": [ {"definitionId": 13, "restValue": "E12345"}]}


    --snip--


    Hope this helps


    Ben

  • Hi I had forgotten about this, I did manage to get a script kinda working, bet then stopped using Jira as our Kanban Board.

    I have attached a skeleton of what I did in the chance it may help someone.

    I used a task schedule to run a powershell script every now and then,  this queried a custom table I had placed in WHD ( Trigger off a field of the ticket when filed changed)  I used an  .ini file to supply all run parameters something like below

    ############################################################
    ##  configuration file for Jira  reporting from WHD
    ##
    ##  Double Hash ##  in line disables the line content
    ##
    ##
    ############################################################


    #Server - yourserverip
    #User - suername
    #DB_Name - whd
    #pword - password
    #Log_File - C:\WHD\log\whd_Log.txt
    #Template - C:\WHD\Report\WHD_TEMPLATE_02.xlsx
    #workDir - C:\WHD\Work


    ## #SMTPserver - smtpserverip  -for production machine
    #SMTPserver - smtp.testip   -testing on za domain

    ##  a list of area's and associated Users that should be processed
    ##  lemail adress seperated by comma's in one line

    # #Area_User_list : xxxxxxx@melitan.co.za ,yyyyyyyE@melitan.co.za

    script a bit long but attached a link

    --snip--

    JIRA_CREATE_ISSUE_ex.ps1 - Google Drive

     

    --snip--

  • Your API Key was visible Be careful.

  • Thanks

    had just removed all references and uploaded the old file