POST request with PowerShell - c#

I have got problem, I need to download graphics from next site
http://www.kakioka-jma.go.jp/cgi-bin/plot/plotSetNN.pl?lang=en
I am using PowerShell, I need to create POST request to Plot the image (see Plot button). The problem that I do now know how it's can be done in PowerShell. Before I used function 'System.Net.WebClient' for downloading, and created url for it with
I googled and find how POST request may be done in C#, and I tried to built them in one script. http://www.everfall.com/paste/id.php?2ppnztfqx3we
But it's not working, it's even do not print "Hello World", and I do not know how to get it's work.
But the main question - not get this code to work, but to find the easiest way to load that graphics, and it would be good if it would on Powershell.
I have seen "Http Rest" script, but it's to hard even to understand does it do what I need, I even do not talk about to modificate it's for my work. I need the simplest way, because my knowledge in programming it now good.

I wrote a series a while back on Splatting (a language technique in PowerShell V2). The last item in the series provides a wrapper on the Net.WebClient class that makes it easier to send requests via Post.
The blog explains a lot about how the client object works, and you can read that if you want:
http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/22/make-windows-powershell-your-web-client.aspx
Or you can download the script directly from the Script Center Repository:
http://gallery.technet.microsoft.com/ScriptCenter/en-us/7e7b6bf2-d067-48c3-96b3-b38f26a1d143
Hope this Helps,

It sounds like curl could be useful for you. It will deal with the trickier aspects of posting data to a web service.
I've used it myself to download text and parse through it with PowerShell. I had a batch file to call curl, the batch file was called from a powershell script. Sounds the long way around but it worked quickly and I didnl't have to put much time in!
I'm on my phone and don't have any examples here, if you interested I can have a look for them later.
HTH,
Matt

Related

Certificate Transparency Logs for C#

Currently working on a certificate transparency logs. My goal is to read each log just like what CertStream - (Open the fire hose button) did, my boss wants to create another one that is written in C#. Just a simple code to parse the logs can really help me. Not necessarily as fancy as CertStream does its stuff.
These are the following links/APIs that I've read:
(API's from Google or related)
https://ct.googleapis.com/pilot/ct/v1/get-sth
https://ct.googleapis.com/logs/argon2020/ct/v1/get-entries?start=20200201&end=20200205
https://www.rfc-editor.org/rfc/rfc6962
Valuable info:
https://certstream.calidog.io/
https://stackoverflow.com/questions/59772797/cant-parse-precertificate-from-certificate-transparency-log
For the code I started,
byte[] byte_LeafInput = Convert.FromBase64String(leaf_input);
byte[] byte_extradata = Convert.FromBase64String(extra_data);
string strLeafInput = Encoding.UTF8.GetString(byte_LeafInput);
string strExtraData = Encoding.UTF8.GetString(byte_extradata);
But it only shows some gibberish data with few readable words.
Any codes or libraries that can help me with that? Upon searching, I found so many codes written in different languages like Python, Go, etc., but based on what I understand in their code, they are also using libraries which is not available in NuGet. X509Certificate might be useful but I don't know how to use it in this case.
Any lead would really be appreciated. Thank you.
Upon searching for a long time. My boss advised me to get the logs and parse it through Python and save that in a text file or csv. After that, my program in C# can use all functions to analyze the information in the created text file. I guess using the current wheel is more efficient than creating one. :)

Is there a good way of extracting data from GUI on Windows OS using python libraries?

I'm currently working on a project which requires me to extract data from GUI on Windows OS - say I need to extract content such as the URL in my browser or the name of the attachment on Gmail.
I have already tried LDTP/Cobra, however it's pretty slow - each request can take up to 5 seconds and I need this library to be reasonably fast. Besides that, the LDTP/Cobra is pretty outdated and the latest MSI file doesn't work with python 3.* unless you modify the library itself.
I've been also researching the pywin API, however, it seems that you can't really extract anything with FindWindowEx and WM_GETTEXT method anymore, but I might be wrong.
My question is - is there any other library that would allow me to extract basically anything from a given Window? Maybe I'm missing an important part of the mentioned libraries? Ideally, I'm looking for a python library, but if there is no other way I could try and write some C# code.

Transferring Skype calls with Skype4Com - is it possible?

I am currently working on a skype plugin / application in c# which I would like to be able to transfer / forward calls to another skype address.
I tried to use ICall.Transfer();, which (as i found out later) basically only transfers files instead of calls.
Then I tried to use ICall.Forward();, but that function tries to send the calls to voicemail and does not allow me to set any other target to forward the call to.
So my question is: Is it possible to transfer / forward a call using basic Skype4Com functions, or should I try to write a workaround involving creating a conference call and then leaving the call, so the 'forwarded' caller is left in the conversation?
I would really like some insight on this.
EDIT:
I solved it. As it turns out the ICall.Transfer(); function was the way to go.
I just overlooked a simple error I made, which could have been prevented with some simple debugging.
using the following:
ICall.Transfer("skype.address");
works, but I was trying to load the skype address dynamically, which had an error somewhere in the process.

How can I get data off of my Windows Phone 7 emulator

I have a unit testing framework for WP7 and it runs on the phone. The results are fairly hard to read so I am writing them to an XDocument.
My question is, how can I then get this XML file off of the phone and onto my desktop where I can actually analyze the results?
What I have done so far is to put a Debugger.Break() line right after where the summary xml is created. I can then copy/paste the xml out of VS or inspect it right in the debugger. The problem is though, that if you don't already have a debugger attached (which is good when lots of ExpectedException tests) Debugger.Attach() seems to not work, also manually attaching VS to the emulator processes seems to do nothing.
I tried running the emulator with some extra command line parameters so I could try to see if I could get it to use my actual hard drive as it's own disk but I couldn't seem to get it to work...
PS it's probably not reasonable to pop open a new process such as a webserver to listen for this data. I know how to do that, I would just rather not.
So how the heck do you get stuff off of these phones??
Have a look at this article about emulator automation from Justin Angel.
It includes details on how to remotely read and write files from/to emulator/device isolated storage.
As you pointed out the other alternative would be to have the applciation send the results to a [local] web server.
The article by Justin Angel is really great, but unfortunately his file-based solution does not work on the final RTM versions of the CoreCon API. Microsoft has simply removed that functionality from the native conman layer.
I've been in the same situation as you and have contemplated various ways to get data out of the device, but in the end only one thing seems to work: as you suggest yourself, pass data to an external webservice.
That solution is less than ideal not only because it takes some effort, but also because of a few caveats:
your app must be granted ID_CAP_NETWORKING capability
network-traffic seems disallowed in the Application_Closing event, and maybe elsewhere too
On the bright side I found that webrequests from the phone, both hardware and emulator, were really fast so the approach works very well (our app is EQATEC Profiler for WP7).

Can I start fiddler from C#?

I'm trying to build a C# application, which uses Fiddler. I saw in the documentation somewhere, that there is supposed to be a function Fiddler.Application.Start or something like that. However, I can't find it. I'd prefer not to write a fiddler extension, because I think it will be more powerful to integrate fiddler into my app. Does anyone know how to do this?
You're really asking about FiddlerCore, which is different than Fiddler. You cannot replicate FiddlerCore by simply wrapping Fiddler.exe.
If you want to automate Fiddler, simply launch it with Process.Start. You can send commands to the FiddlerScript engine using the ExecAction executable.
Incidentally, neither Fiddler nor FiddlerCore is a COM object.
You can just do a System.Diagnostics.Process.Start() on the fiddler EXE, no?
Is this what you are looking for?
"Please note: FiddlerCore is currently undergoing a limited, Microsoft-Internal alpha. At present, there is no timeline for a broader release." http://fiddler.wikidot.com/fiddlercore
So, it appears there is no way to get FiddlerCore unless you work for Microsoft.

Categories

Resources