ServiceNow Import Set API POST

Welcome Forums General PowerShell Q&A ServiceNow Import Set API POST

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 10 months ago.

  • Author
  • #54928

    Topics: 2
    Replies: 28
    Points: 0
    Rank: Member

    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

    Topics: 18
    Replies: 573
    Points: 32
    Rank: Member

    You know you could just email me:D

The topic ‘ServiceNow Import Set API POST’ is closed to new replies.