Forum Discussion

kgrandy's avatar
kgrandy
New Contributor
4 years ago

Is it possible for TestRunner API without cURL using PowerShell Invoke Method

Trying to avoid running cURL commands in our architecture.  Is it possible for TestRunner API without cURL using PowerShell Invoke Method

 

I seem to be haveing difficulty here is the psude code I am trying to execute...

 

PS C:\Users\%USER%> Invoke-RestMethod -Method POST -ContentType "application/json" -uri "http://localhost:1880/1/suites" -Body @C:\source\apiTest.zip
Invoke-RestMethod : {"success":false,"errorMessage":"The specified data is not a valid ZIP file."}
At line:1 char:1
+ Invoke-RestMethod -Method POST -ContentType "application/json" -uri " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

  • Multipart/form-data does work when adding as content type. The problem I had here is the API needed some parameters to accept raw content, then I was able to use -InFile \path\to\file and upload using Invoke-RestMethod subway gift card balance

  • Hudson1998's avatar
    Hudson1998
    Occasional Visitor

    Multipart/form-data does work when adding as content type. The problem I had here is the API needed some parameters to accept raw content, then I was able to use -InFile \path\to\file and upload using Invoke-RestMethod subway gift card balance

    • kgrandy's avatar
      kgrandy
      New Contributor

      I was able to upload via PowerShell using this code:

       

      $Test = Invoke-RestMethod -uri "http://localhost:1880/1/suites" -ContentType "application/zip" -Method Post -Infile C:\tests\api_tests\apiTest.zip

       

      now we are having issues with authentication... can I just wrap that into the header?