Questions tagged [invoke-restmethod]
129 questions
1
vote
0 answers
PowerShell - Invoke-RestMethod return partial response
I'm running a GET Rest request using PowerShell Invoke-RestMethod command.
When trying to run the same API on a browser, I'm getting a full JSON file with full content.
But when running using PowerShell Invoke-RestMethod, some parameters are not…

ShaiO
- 153
- 1
- 10
1
vote
0 answers
How do I encode a response from Powershell Invoke-RestMethod command to unicode?
I am making an API call to a system that is supposed to return a list of names.
$headers=@{}
$headers.Add("Accept", "application/json;charset=UTF-8")
$headers.Add("Authorization", "secretkey")
$people= Invoke-RestMethod -Uri 'https://someAPI'…

Agneum
- 727
- 7
- 23
1
vote
1 answer
Using powershell Invoke-RestMethod to GET multipart content
I am trying to process a multipart GET call in powershell and then save the zipfile it contains to disk. I can execute this:
$response = Invoke-RestMethod -Uri $reqUrl -Method Get -Headers $headers
and then echo out the filename and contents. In…

Mark Chassy
- 159
- 3
- 13
1
vote
0 answers
PowerShell Start-Transcript stops logging after POST API call
I have a PowerShell script which invokes POST REST API calls to Microsoft Graph. At the start of the script, I use the Start-Transcript -Append "$($MyInvocation.MyCommand.Name).log" cmdlet and at the end of the script, I use the Stop-Transcript…

Theosis
- 11
- 4
1
vote
0 answers
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send
I am trying to run citrix api through powershell but it is giving me error
The underlying connection was closed: An unexpected error occurred on a send.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor…

Jithin Jeffry
- 13
- 1
- 4
1
vote
1 answer
How To Correctly Use Jenkins PowerShell step to call Web API using Invoke-WebRequest or Invoke-RestMethod
I am using Jenkins, in a PowerShell command step, to call a Web API service. I am calling the service using Invoke-WebRequest.
This service call has to be in Jenkins, because I need to do it only if other Jenkins jobs have completed…

MikeDev
- 357
- 1
- 2
- 20
1
vote
0 answers
PowerShell - CURL returns values and nodes while Invoke-RestMethod returns empty nodes
If I use curl in windows CMD to get my result I am getting nodes with result (it's a single line CURL I am putting it as multiple for better overview):
curl --request POST "https://app.io/Id=Xz"
--header "x-api-key: WHp" --header "Content-Type:…

vel
- 1,000
- 1
- 13
- 35
1
vote
1 answer
Invoke-RestMethod returning 401 - Unauthorized in Powershell 7
I'm running into an issue trying to use the Invoke-RestMethod command in PowerShell 7. I can get it to run fine in PowerShell 5.1, but 7 gives me a 401 - Unauthorized message.
Here's the command for PowerShell 5.1:
Invoke-RestMethod…

JR_M
- 127
- 1
- 8
1
vote
1 answer
Calculate values from results of Invoke-RestMethod in PowerShell
I am able to get data back via Invoke-RestMethod from an API which provides the below format:
1612142668000000000 : @{peak_performance=29.18; current_utilization=19.15}
1612146268000000000 : @{peak_performance=29.05;…

Dustjunky
- 13
- 2
1
vote
0 answers
Invoke-RestMethod returns "The underlying connection was closed", URL shows "Connection was reset"
I'm trying to send a body of JSON using PowerShell from several systems to my Flask website.
While it works on most of my systems, but fails on some of my systems and I couldn't figure out why..
PowerShell command:
$res = Invoke-RestMethod -Method…

wk14
- 197
- 1
- 7
1
vote
2 answers
CURL - Powershell : Invoke-RestMethod to GLPI API : Upload Document
I would like to upload a file to my GLPI from API.
This curl command works fine :
curl -X POST
-H 'Content-Type: multipart/form-data'
-H 'Session-Token: $sessiontoken'
-H 'App-Token:$apptoken'
-F 'uploadManifest={"input": {"name": "Uploaded…

Dead-Red
- 21
- 4
1
vote
1 answer
Powershell Invoke-RestMethod - Handling special characters in Uri
In powershell I am calling a rest API using Invoke-RestMethod. I am passing query string arguments whose values can have special characters and they are causing errors.
$x = Invoke-RestMethod -Uri "https://.com?Key=
Everything…

user15360876
- 23
- 4
1
vote
1 answer
Post multi-part body with PowerShell Invoke-RestMethod
Using Postman the API call works. I used their code snippet feature to get the PowerShell equivalent. But when I try it on PowerShell ISE I get "Empty request body not allowed". Why does it think the body is empty? How can I confirm/look at the…

LostInTheBitBucket
- 11
- 2
1
vote
0 answers
Invoke-Webrequest | Invoke-RestMethod - Powershell question marks instead of hebrew
I'm trying to send a post with Invoke-Webrequest / Invoke-restmethod in 2 scenarios. one of them is working well and the other is working but replacing Hebrew letters with question marks...
This one is working well:
json = @{
"contactID"= "my…

Moshiko
- 29
- 5
1
vote
1 answer
Do-untill loop getting error (powershell)
Try to convert a web request from JSON but always get the below error:
Method invocation failed because [Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject] does not contain a method named 'op_Addition'.
At…

G. Micskei
- 43
- 1
- 11