locked
Unable to submit form on web page using Invoke-WebRequest RRS feed

  • Question

  • Looking to automate the Web search on HP's website by serial number to get the warranty data.  I am able to successfully get back the web page, and I can populate the fields in the form. However, when I submit the POST, I don't seem to get back any data.

    Please look at the below script and tell me what I'm doing wrong. I am following the FACEBOOK "Example 2" from the Get-Help in PowerShell 3.0.

    $Serial = "CND1076GST"
    $Url = "http://h20566.www2.hp.com/portal/site/hpsc/public/wc/home/"
    $r = Invoke-WebRequest -Uri $Url -SessionVariable HP
    
    If ($r.StatusDescription -eq "OK" ) {
        Write-Host $r.StatusDescription
        $HP
        $form = $r.Forms.Item("wcFormDataItem")
        $form.Fields["serialNumber0"] = $Serial
        $r2 = Invoke-WebRequest -Uri ($Url + $form.Action) -WebSession $HP -Method POST -Body $form.Fields
        $r2.Content | Out-File c:\temp\test.htm -Force
        Write-Host $r2.StatusDescription
    } Else {
        Write-Host $r.StatusDescription
    }


    Levi Stevens | Technical Consultant Dell Services

    Thursday, January 16, 2014 12:10 AM

Answers

  • HP has no documented web service, and I'm not sharp enough of a web developer to decode their web service call. Was hoping someone else might be able to nail it out. I called HP Warranty team, and they told me to email them a list of machines and they would email back in 2 days. Not really a sustainable/automatable process. ;)

    Levi Stevens | Technical Consultant Dell Services

    • Marked as answer by Bill_Stewart Tuesday, June 24, 2014 7:59 PM
    Thursday, January 16, 2014 12:43 AM

All replies

  • Internal postbacks are notorious impossible to automate.  We use web services because of that.  The chances are the backend is a web service and the page is dynamically generated on the browser.  This cannot be done via a web client post or get.  It is done in code and XML is returned.  If you can decode the web service call you can probably call it directly.


    ¯\_(ツ)_/¯

    Thursday, January 16, 2014 12:30 AM
  • HP has no documented web service, and I'm not sharp enough of a web developer to decode their web service call. Was hoping someone else might be able to nail it out. I called HP Warranty team, and they told me to email them a list of machines and they would email back in 2 days. Not really a sustainable/automatable process. ;)

    Levi Stevens | Technical Consultant Dell Services

    • Marked as answer by Bill_Stewart Tuesday, June 24, 2014 7:59 PM
    Thursday, January 16, 2014 12:43 AM
  • This is how easy it is to lookup the same data from Dell.

    $GUID = "cac8daa8-6699-466b-a3d3-f07e571fba1f"
    $AppName = "Dell Warranty"
    $ServiceTag = "5LCQSY1"
    $WebProxy=New-WebServiceProxy -Uri http://xserv.dell.com/services/assetservice.asmx
    $WarrantyInformation=$WebProxy.GetAssetInformation($GUID,"Dell Warranty",$ServiceTag)
    $WarrantyInformation | Select-Object -ExpandProperty Entitlements
    


    Levi Stevens | Technical Consultant Dell Services

    Thursday, January 16, 2014 3:23 AM