ServiceNow Import Set API POST

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dan Potter Dan Potter 2 weeks, 2 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #54928
    Profile photo of Edmond Yee
    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
    Profile photo of Dan Potter
    Dan Potter

    You know you could just email me:D

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.