httprequest

How to change output of Invoke-WebRequest?

梦想的初衷 提交于 2019-12-25 03:13:36
问题 I want to be able to get the results of Invoke-WebRequest and have my script print either "Failed" if the server was not reached or "Online" if it was reached. This is what I'm doing to try to do that. $IW_Results = $Servers_to_Check | ForEach-Object { Invoke-WebRequest -Uri $_ } $err = $IW_Results | ?{$_.gettype().Name -eq "ErrorRecord"} if($err){ Write-Output "Failed" } else { Write-Output "Online" } I was able to get the script to print "Online" if the server is reached. However when it

JavaScript POST request

随声附和 提交于 2019-12-25 02:44:57
问题 How is it possible to enable the following JavaScript function, sending a POST request, to recieve productID parameter not as a single string variable but as a collection of productID 's? i.e. to get in output a string like: "productId=126504&productId=126505&productId=126506&productId=126507&productId=126508" <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> function addToCart(productId, returnUrl) {

AngularJS salesforce attachment with Http request - Troubleshooting help needed

ぐ巨炮叔叔 提交于 2019-12-25 02:44:26
问题 I wrote this in AngularJS service block and I can't get it to work properly: app.factory('sfAttachment', ['$http', '$q', '$window', function($http, $q, $window){ var attachment = {}; //Save to server function for attachments attachment.save = function( base64value, mimeType, currentDocTypeId, currentFilename, attachmentId ){ var data = { "Body" : base64value, "ContentType": mimeType, "ParentId": currentDocTypeId, "Name": currentFilename }; var url = $window.__url; var method; var isUpdate = (

perform httprequest in batch file

让人想犯罪 __ 提交于 2019-12-25 02:38:41
问题 I have created a batch file (.cmd) to perform numerous tasks when installing a web application One of the tasks I want to perform is start the web application by performing a http request to the sites homepage. How can I do this? I would prefer not to have to use any external libraries or the like if possible. 回答1: You will need to use wget, which is a command-line utility that can be used to retrieve webpages. 来源: https://stackoverflow.com/questions/4284866/perform-httprequest-in-batch-file

Angular 2+ HTTPRequests get data from multiple Charts asynchronously in one method for a chart

↘锁芯ラ 提交于 2019-12-25 02:19:11
问题 I have a ngx-chart, where I want to insert some data from 2 or more different Mongodb Tables. So I have to make HTTPRequests to two different routes, because each route queries its own Collection/Tables in mongodb. How can I do this inside one big method to get all the data in one chart? Because the requests are asynchronous, I would have to do the data manipulation for the chart inside the HTTP-Request method... that would be OK if I only query from one route (or one table). But as I have to

How to POST from JS or node.js?

与世无争的帅哥 提交于 2019-12-25 01:37:25
问题 I want to do the following POST command from my JS or node.js file. terminal.zsh curl -L --data-binary @data/scrape.csv https://script.google.com/macros/s/#/exec I can successfully write my .csv file from my node.js file with the following code. node.js const ObjectsToCsv = require('objects-to-csv'); const itemsAsCsv = new ObjectsToCsv(formattedItems); itemsAsCsv.toDisk(filePathCsv, { allColumns: true, }); I have unsuccessfully tried the following. I expect to see the data hit my API but

Python HTTP request with json data isn't getting php response with json data

北城余情 提交于 2019-12-25 01:25:29
问题 I am trying to send a python http request with some json data (I will use this json data in a later case) to server. Server should give a response with some json data (using PHP). Unfortunately there is no any response even though request status code is 200. Any help please! #request.py import requests import urllib3 import json import os import time import sys #http Request url = 'http://localhost/response.php' headers = {'Content-type': 'application/json', 'Accept': 'application/json'}

Login to a website using POST and HttpRequest

感情迁移 提交于 2019-12-25 01:16:56
问题 There is a website I need to login using HttpRequest. The login form of said website uses POST method. I know how to use HttpRequest for pages with no protection, how can I login to a website using POST? 回答1: This example is by the courtesy of http://www.netomatix.com. The POST is set to the HttpWebRequest.Method property in the OnClick handler in code behind. Example form: <form name="_xclick" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden"

C# equivalent for PowerShell Invoke-RestMethod -Token

偶尔善良 提交于 2019-12-24 23:20:07
问题 I have a PowerShell script that I want to rewrite in C# (initially I wanted to call the PowerShell script from C#, but here it turned out that rewriting it is propably easier and more elegant). So this is the PowerShell code I need to port to C#: $uri = "$BaseUri/auth/token" $bodyJson = ConvertTo-Json @{token = $ApiToken} -Compress $response = Invoke-RestMethod ` -Uri $uri ` -Method Post ` -ContentType "application/json" ` -Body $bodyJson $jwtToken = $response.token #jwtToken is then used to

C# equivalent for PowerShell Invoke-RestMethod -Token

橙三吉。 提交于 2019-12-24 22:41:18
问题 I have a PowerShell script that I want to rewrite in C# (initially I wanted to call the PowerShell script from C#, but here it turned out that rewriting it is propably easier and more elegant). So this is the PowerShell code I need to port to C#: $uri = "$BaseUri/auth/token" $bodyJson = ConvertTo-Json @{token = $ApiToken} -Compress $response = Invoke-RestMethod ` -Uri $uri ` -Method Post ` -ContentType "application/json" ` -Body $bodyJson $jwtToken = $response.token #jwtToken is then used to