ServiceNow Import Set API POST

This topic contains 1 reply, has 2 voices, and was last updated by  Dan Potter 1 year, 8 months ago.

  • Author
  • #54928

    Edmond Yee

    Does anyone have experience using Invoke-RESTMethod to POST to the ServiceNow Import Set API? I tried to do it the same as connecting directly to the tables (code below), and I end up with a 'Too many automatic redirections were attempted.' error. I saw a few articles referencing that you need to store cookies but I am not sure how to do this.

    $POSTuri = ''
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add('Authorization',('Basic YJH%#IOJ#GGdfgdsfXBpX2Jn3jhkl390f329213nkjfasfpX2l0YWM6QVNET01XMjasdfas33$#%^45M2Mz$K%#%'))
    # Specify request body
    $body = @{
        'assigned_to' = 'Edmond Yee'
        'work_notes' = 'Assigning ticket to me. Test 10/4/16 11:20am'
        'number' = "$item"
    }#end body
    $json = $body | ConvertTo-Json
    Invoke-WebRequest -Method Post -Headers $headers -Uri $POSTuri -Body $json
  • #54930

    Dan Potter

    You know you could just email me:D

You must be logged in to reply to this topic.